Note that there are some explanatory texts on larger screens.

plurals
  1. POEntering variables into regression function
    primarykey
    data
    text
    <p>I have this feature_list that contains several possible values, say "A", "B", "C" etc. And there is time in time_list.</p> <p>So I will have a loop where I will want to go through each of these different values and put it in a formula.</p> <p>something like <code>for(i in ...)</code> and then <code>my_feature &lt;- feature_list[i]</code> and <code>my_time &lt;- time_list[i]</code>.</p> <p>Then I put the time and the chosen feature to a dataframe to be used for regression</p> <pre><code>feature_list&lt;- c("GPRS") time_list&lt;-c("time") calc&lt;-0 feature_dim &lt;- length(feature_list) time_dim &lt;- length(time_list) data &lt;- read.csv("data.csv", header = TRUE, sep = ";") result &lt;- matrix(nrow=0, ncol=5) errors&lt;-matrix(nrow=0, ncol=3) for(i in 1:feature_dim) { my_feature &lt;- feature_list[i] my_time &lt;- time_list[i] fitdata &lt;- data.frame(data[my_feature], data[my_time]) for(j in 1:60) { my_b &lt;- 0.0001 * (2^j) for(k in 1:60) { my_c &lt;- 0.0001 * (2^k) cat("Feature: ", my_feature, "\t") cat("b: ", my_b, "\t") cat("c: ", my_c, "\n") err &lt;- try(nlsfit &lt;- nls(GPRS ~ 53E5*exp(-1*b*exp(-1*c*time)), data=fitdata, start=list(b=my_b, c=my_c)), silent=TRUE) calc&lt;-calc+1 if(class(err) == "try-error") { next } else { coefs&lt;-coef(nlsfit) ess&lt;-deviance(nlsfit) result&lt;-rbind(result, c(coefs[1], coefs[2], ess, my_b, my_c)) } } } } </code></pre> <p>Now in the <code>nls()</code> call I want to be able to call my_feature instead of just "A" or "B" or something and then to the next one on the list. But I get an error there. What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload