I have a problem and I am relatively new to program R. I have the following function
b=1
l=1
e=1
fitcv=glm(global radiation~poly(latitude,b)+poly(longitude,l),data=dataframe)
model=1:10
cv.error10=rep(10)
for (b in model) {
for(l in model){cv.error10[e]=cv.glm(dataframe,fitcv,K=10)$delta[1]
e=e+1
}}
plot(cv.error10,type="b",xlab="Number of polynomials",ylab="Error in cross-validation", main="Error in different orders")
cv.error10
which.min(cv.error10)
Now unfortunately the calculation takes very long, is there a variant for this which perhaps executes this faster?
Many thanks to you all