Federico Calboli <f.calboli <at> imperial.ac.uk> writes:

> 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?

  I haven't tested it (don't want to bother to put together the
test data), but does nrow(model.frame(my.model)) work ?

______________________________________________
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.

Reply via email to