0

After typing:

glm.fit=glm(Y[[1]]~.,data=X)
library("boot")
glmE=cv.glm(X,glm.fit,K=3)

I get the following error:

Error in model.frame.default(formula = Y[[1]] ~ ., data = list(x1 = c(1L, : długości zmiennych różnią się (znaleziono dla 'x1')

The last line is: variable lengths differ (found for 'x1')

X is the data frame of inputs (predictors), and Y is the output data frame. I have this problem with real data, just put this for simplicity.

What should I change to make it work, preferably without merging inputs and outputs(X,Y) ?

Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
  • The error says it all, the variables should have the same length `glm(runif(10) ~ runif(9))` – Rorschach Oct 18 '15 at 20:27
  • Thank you for editing my question, it is my first post so sorry for inconvenience. I forgot to tell that the lengths (number of observations) of X, Y are the same, and the error pops up after cv.glm not glm function. I found it explained here: http://stackoverflow.com/questions/28350357/cv-glm-variable-lengths-differ. However i would like to use numbers (to put it in for loop), not names of variables because they are complicated and number of variables is very big. So the solution presented there isn't working for me. – Konrad L Oct 18 '15 at 21:12

0 Answers0