3

I need to write the following model in equation form for a paper:

enter image description here

Is the following equation describing the model correctly?

enter image description here

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) } }

  • 2
    Why not just perform that calculation on your data and confirm it agrees with the values returned by the predict function? 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
  • this is not for checking purposes, cf. edit – magisterludi Oct 07 '22 at 15:59
  • 2
    I hope you would want to check anything you put into a publication. – whuber Oct 07 '22 at 16:18

1 Answers1

1

Because you used raw and not orthogonal polynomials, the fitted model could be written as follows (with four significant digits): $$ \widehat{ROI}_i=-39.15-0.5117\times Freq_i + 0.004323\times Freq^{2}_{i} $$

COOLSerdash
  • 30,198