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
 
     
    