Hi all, I am running OLS models with a power parameter: y=a+bx^p, and I want to iterate through p with a set increment. The function I constructed is something like below:
test<-function(data, model,...){ f<-formula(model) #model="y~I(x^p)" p<-0.1 n<-10 result<-list() while (p<=1) { for (i in 1:n) { result[[i]]<-lm(data, formula=f...) p<-p+0.1 } } return(result) } The problem I am facing is that the loop does not assign or update p values. I also tried a nested for loop starting with "for (p in seq(0.1,1,0.1)){for (i in 1:n) {..." but it did not work either. After the initial value of p is assigned, the inner loop is executed but p is not updated. Any help is greatly appreciated. best, quan ______________________________________________ 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.