Reputation: 33
I am new in using R and I am not familiar with the writing R loops. I need you to help me out of the following R programing. The objectives of the R code is to get the AIC for all the model with different df.
The R code that I have written were:
library(splines)
library(dlnm)
For (i in 1:30)
argvar1 <-list(type="bs", df=2[i],cen=50)
arglag1<- list(type="ns",df=3)
cb1 <-crossbasis(AFH6w,lag=24,argvar=argvar1,arglag=arglag1)
argvar2 <-list(type="ns", df=11, cen=-2)
arglag2 <- list(type="ns",df=3)
cb2 <-crossbasis(OutTw,lag=24,argvar=argvar2,arglag=arglag2)
model1 <-lm(NH3cH6w~ cb1 +cb2+DenH6w+as.factor(Month))
AIC[i]=AIC(model1)
}
I think there are problems with the last line but I cannot figure it out after exhausted struggling.
I will really appreciate your help!
Shule
Upvotes: 0
Views: 269
Reputation: 330453
You are missing opening curly brackets and for
should be lowercase:
for (i in 1:30) {
argvar1 <-list(type="bs", df=2[i],cen=50)
arglag1<- list(type="ns",df=3)
...
}
Other than that it is hard to say. Please read How to make a great R reproducible example? before posting.
Upvotes: 1