0

im trying to use glm like so: model<- glm(y~radius + symmetry, data = train) where radius and symmetry are numeric vectors and i receive the following error:

Error in model.frame.default(formula = y ~ radius + symmetry, data = train,  : 
  invalid type (list) for variable 'y'

using str(train$radius) i received the following:

 num [1:469] 19.21 13.15 14.86 19 8.73 ...

using str(train$symmetry) i received the following:

 num [1:469] 0.192 0.182 0.157 0.195 0.165 ...

y is expecting two vectors and is getting them. then why do i have an error?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 2
    Do you have a variable named `y` in your data.frame `train`? What does `str(data$y)` return? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Jul 07 '20 at 20:51
  • sorry.this is my first time publishing a question and therefore i haven't mastered the craft yet. i havent got a variable named y in my data and str(data$y) returns NULL. its a bit difficult to include an example since this might be specific to the data im using or in general with the glm function and i really don't know how to address the problem. i have read many examples on line but not managing to solve the problem. – uriel Cole Jul 08 '20 at 11:57
  • Then the formula you are passing to glm doesn’t make sense. In your modeling what are your dependent and independent variables? What are you trying to predict or model? – MrFlick Jul 08 '20 at 16:47
  • I was really stupid. The formula wasn't right and I needed to put it in as factor – uriel Cole Jul 09 '20 at 17:36

0 Answers0