Hello,
I am trying to apply a least squares non-linear regression to my dataset, dem16. I can apply it to a subset based on a single site fine, but I want to apply it to each (of 197) sites. I am stumbling over a "for" loop. Site and Mean_Air are variables in my dataset and I would like to estimate alpha, beta, gamma, mu and Tw for each site. I have over 50,000 observations in my dataset.


results <- c()
for (i in Site) {
results[i]<- nls(Tw ~ mu + ((alpha - mu)/(1 + exp(gamma*(B - Mean_Air)))),
        data = dem16,
        start = list(mu = 0.0001, alpha = 21.8, gamma = 0.22, B = 12.8))
        }

Thank you in advance,
Ingrid

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to