Dear R-experts, I am having trouble while doing crossvalidation with a MARS regression including an interaction term between a factor variable (education) and 1 continuous variable (age). How could I solve my problem ?
Here below my reproducible example. ####### install.packages("ISLR") library(ISLR) install.packages("earth") library(earth) a<-as.factor(Wage$education) # Create a list to store the results lst<-list() # This statement does the repetitions (looping) for(i in 1 :200) { n=dim(Wage)[1] p=0.667 sam=sample(1 :n,floor(p*n),replace=FALSE) Training =Wage [sam,] Testing = Wage [-sam,] mars5<-earth(wage~age+education+year+age*a, data=Wage) ypred=predict(mars5,newdata=Testing) y=Testing$wage y=Wage[-sam,]$wage MSE = mean(y-ypred)^2 MSE lst[i]<-MSE } mean(unlist(lst)) summary(mars5) ####### ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.