Having trouble with a bootstrap approach - creating a function for cross validation

Hello

I am writing up a cross validation code to check that my model using the lm() is correct.

Here is the code below:

boot.fn_malta <- function(data, index)
return(coef(lm(GDP ~ Manufacturing + FDI + FDIManf, data = df_malta_clean)))

boot.fn_malta(df_malta_clean, 1:nrow(df_malta_clean))

boot(df_malta_clean, boot.fn_malta, 1:nrow(df_malta_clean))

my data frame is df_malta_clean. The predictor FDIManf is an interaction term using the predictors: Manufacturing and FDI. I have only 35 observations so that is why I am using the bootstrap approach. When I run this code, I am getting this error message

boot(df_malta_clean, boot.fn_malta, 1:nrow(df_malta_clean))
Error in sample.int(n, n * R, replace = TRUE) : invalid 'size' argument

I don't understand why it is giving me this invalid size argument. Can someone please help?

Thank you

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.