[R] Keeping NAs in model.matrix for glm.fit

Ted tchiang at sickkids.ca
Thu Oct 29 16:31:45 CET 2009


Hi,

For efficiency purposes I'm using glm.fit instead of glm, and I'm 
pre-constructing a model design matrix using model.matrix().

I'm finding that the 'NAs' in the x are being removed by model.matrix by 
default, and would like to know how could I keep them (or remove the 
corresponding NAs in the Y) so that the length for both response and 
predictor would be the same.  Thanks for your reply.


myformula = ~ offset(Bgrid[i,1] * x)

MM <- model.matrix(myformula)

alpha[i] <- coef(glm.fit(MM, Y, family=binomial()))


Ted

-------------------------------------
Ted Chiang
  Bioinformatics Analyst
  Centre for Computational Biology
  Hospital for Sick Children, Toronto
  416.813.7028
  tchiang at sickkids.ca




More information about the R-help mailing list