1

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

  • 2
    You may attract good answers if you'd make your code reproducible and share some data, read [how-to-make-a-great-r-reproducible-example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) – jay.sf Jun 07 '20 at 09:59

0 Answers0