I need to write the following model in equation form for a paper:
Is the following equation describing the model correctly?
Edit: I forgot to mention that this is a machine learning model. The purpose of the equation is simply to state it in the methodology in a paper not to calculate anything. Here is the code used:
df.shuffled <- fullsample5[sample(nrow(fullsample5)),]
#define number of folds to use for k-fold cross-validation
K <- 100
#define degree of polynomials to fit
degree <- 5
#create k equal-sized folds
folds <- cut(seq(1,nrow(df.shuffled)),breaks=K,labels=FALSE)
#create object to hold MSE's of models
mse = matrix(data=NA,nrow=K,ncol=degree)
#Perform K-fold cross validation
for(i in 1:K){
#define training and testing data
testIndexes <- which(folds==i,arr.ind=TRUE)
testData <- df.shuffled[testIndexes, ]
trainData <- df.shuffled[-testIndexes, ]
#use k-fold cv to evaluate models
for (j in 1:degree){
fit.train = lm(ROI ~ poly(Freq,j), data=trainData)
fit.test = predict(fit.train, newdata=testData)
mse[i,j] = mean((fit.test-testData$Freq)^2)
}
}


predictfunction? Even when you are absolutely sure of the answer, such a check confirms the software is doing what you think it should do. – whuber Oct 07 '22 at 15:35