[R] logistic regression - unequal groups in R

David Winsemius dwinsemius at comcast.net
Thu Feb 26 02:04:38 CET 2009


On Feb 25, 2009, at 7:36 PM, ekwaters wrote:

>
> I am getting a repeated error when I try to run a logistic  
> regression in R
> 2.8.1
>
>> (glm(prop1~x1,data=glm1,family=binomial("logit"),weights=nt1))
> Error in model.frame.default(formula = prop1 ~ x1, data = glm1,  
> weights =
> nt1,  :
>  invalid type (list) for variable 'x1'

The interpreter was expecting a vector for x1 and you gave it a list.

>
>
> x1 is multistate categorical (3 categories). 2 of the categories  
> have 12
> observation, one has 9. Is this what it is objecting to?

Doubtful.

>
>
> Do I have to have equal numbers of observations of all categories in  
> R?

No.
>
>
> nt1 is the total number of events for which p1 is the success  
> proportion,
> each is linked with a category, vis..
>
>> list(glm1)
> [[1]]
>           V1 V1 V1
> 1  1.00000000 cc 10
> 2  0.73333333 cc 15
> 3  0.04761905 cc 21
>
> etc....

Does not look like a properly constructed dataframe. Such would not  
have had three columns with identical names. What does str(glm1) show?

-- 
David Winsemius
>
>
> Probably a newbie error either in data setup, but assistacne would be
> appreciated.
>
> Ned
> -- 
> View this message in context: http://www.nabble.com/logistic-regression---unequal-groups-in-R-tp22215299p22215299.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list