Dear Jarrod, If you use na.action=na.exclude in fitting the model, then you can produce rows of NAs in the model matrix with na.resid(); e.g., for a model m,
mm <- naresid(m$na.action, model.matrix(m)) Then if you really want to convert the rows of NAs in mm to 0s, you could use mm[is.na(mm)] <- 0 I hope this helps, John ------------------------------ John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Jarrod Hadfield > Sent: December-28-08 8:13 AM > To: r-help@r-project.org > Subject: [R] model.matrix and missing values > > Hi, > > Does anyone know an easy way of retaining rows in a model.matrix where > missing values are present in the predictors. Ideally I'd be able to > retain these rows as zeros. > > Thanks, > > Jarrod > > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.