Skip to content
Prev 319727 / 398503 Next

How many samples ACTUALLY used in regression?

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