Klaus (Diego)
2008-Feb-13 21:13 UTC
[R] Error in model.frame.default: invalid type (list) for variable ...
I'm getting the following errors when I try to execute the glm() procedure:
If my matrix of predictors is a data.frame, R shows me this error:
Error in model.frame.default(formula = Ycentro ~ metodocentro - 1, data
metodocentro, :
invalid type (list) for variable 'metodocentro'
If my matrix of predictors isn't a data.frame, R shows me this one
Error in model.frame.default(formula = Ycentro ~ metodocentro - 1, data
metodocentro, :
'data' must be a data.frame, not a matrix or an array
I'm using this version of R:
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 6.1
year 2007
month 11
day 26
svn rev 43537
language R
version.string R version 2.6.1 (2007-11-26)
And here are some examples of the response variable and the predictors:
Ycentro is my response variable, it has 248 rows of 0's and 1's:
[,1]
[1,] 1
[2,] 1
[3,] 1
[4,] 1
[5,] 1
[6,] 1
[7,] 1
[8,] 1
[9,] 1
[10,] 1
while metodocentro is my matrix of predictors, it has this format:
vies13 centro13x1 centro13x2 vies23 centro23x1 centro23x2
[1,] 1 18.009066 27.414592 0 0.00000 0.000000
[2,] 1 10.457802 15.485570 0 0.00000 0.000000
[3,] 1 16.828764 27.652697 0 0.00000 0.000000
[4,] 1 18.807218 40.238635 0 0.00000 0.000000
[5,] 1 23.025113 45.918713 0 0.00000 0.000000
[6,] 1 27.861487 30.397026 0 0.00000 0.000000
[7,] 1 23.845959 27.193986 0 0.00000 0.000000
[8,] 1 10.557285 31.366402 0 0.00000 0.000000
[9,] 1 22.811078 27.074102 0 0.00000 0.000000
[10,] 1 12.309584 44.193660 0 0.00000 0.000000
Thanks you for your patience
Diego
[[alternative HTML version deleted]]
Klaus (Diego)
2008-Feb-14 15:03 UTC
[R] Error in model.frame.default: invalid type (list) for variable ...
I got it right now, It wasn't working because the matrix of predictors had the same name as the dataset, so I modified the call creating a dataset with the response and predictors and keeping the data.frame using the same name metodocentrod <- data.frame(metodocentro) resultadocentro <- glm(Ycentro ~ metodocentro-1, family = binomial(link "logit"), data=metodocentrod) Thanks for the help, because of your e-mail I could figure this out. [[alternative HTML version deleted]]