[R] How many samples ACTUALLY used in regression?

Federico Calboli f.calboli at imperial.ac.uk
Mon Mar 18 13:36:53 CET 2013


Dear All,

is there a simple way that covers all regression models to extract the number of samples from a data frame/matrix actually used in a regression model?

For instance I might have a data of 100 rows and 4 colums (1 response + 3 explanatory variables).  If 3 samples have one or more NAs in the explanatory variable columns these samples will be dropped in any model:

my.model = lm(y ~ x + w + z, my.data)
my.model = glm(y ~ x + w + z, my.data, family = binomial)
my.model = polr(y ~ x + w + z, my.data)
…

I don't seem to be able to find one single method that works in the exact same way -- irrespective of the model type -- to interrogate my.model to see how many samples of my.data were actually used.  Is there such function or do I need to hack something together?

Best wishes

Federico



More information about the R-help mailing list