[R] Is glm weird or am I?

roy wilson rwilson+ at pitt.edu
Thu Jan 27 20:54:06 CET 2005


Hi,

I've written a script that checks all bivariate correlations for 
variables in a matrix. I'm now trying to run a logistic regression on 
each pair (x,y) where y is a factor with 2 levels. I don't know how (or 
whether I want) to try to fathom what's up with glm.

What I wrote is attached. Here's what I get.

*****************************************************

source("lrtest.R")
building model: Wgend ~ WAY
construct_and_run_model:
class of x: integer nlevels(x): 0
class of y: factor nlevels(y): 2
  model built
  model ran
-1.070886   0.01171153
building model: Wgend ~ WBWS
construct_and_run_model:
class of x: integer nlevels(x): 0
class of y: factor nlevels(y): 2
  model built
  model ran
0.0837854   0.01898052
building model: Wgend ~ Wcond
construct_and_run_model:
class of x: factor nlevels(x): 2
class of y: factor nlevels(y): 2
Error in "contrasts<-"(`*tmp*`, value = "contr.treatment") :
        contrasts can be applied only to factors with 2 or more levels

*********************************************************************

Both Wcond and Wgend take values in {1,2}. My understanding is that, 
when family is bonomial, GLM recodes these to {0, 1}. That's consistent 
with what I've seen previously.

Excuse the possible stupidity :-).

Roy
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: lrtest.R
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20050127/8a551f7e/lrtest.pl


More information about the R-help mailing list