[R] passing model objects to anova()
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Tue May 28 13:12:13 CEST 2002
On Tue, 28 May 2002, David Orme wrote:
> Hi,
>
> I'm fitting a glm to a dataset...
>
> > objects()
> [1] "pop.div.full" "speciation.data"
>
> ...and then performing model simplification to give a series of model
> objects all of which have a common suffix.
>
> > objects()
> [1] "pop.div.full" "pop.div.gp.f.b.hm"
> [3] "pop.div.gp.fb.hm" "pop.div.same.slopes"
> [5] "speciation.data"
> I am using anova(model1, model2...) to test the significance of term
> deletion within the series of models. Is there any way to pass
> objects() called with a pattern to anova(). i.e something like...
>
> > anova(list = objects(pattern="pop.div"),test="Chisq")
>
> instead of
>
> > anova(pop.div.full, pop.div.gp.f.b.hm, pop.div.gp.fb.hm,
> >pop.div.same.slopes,test="Chisq")
>
> OK, in this example it isn't a lot of typing/cut and paste but it
> could be quite handy if there is a simple way of doing it,
> particularly when I have more than one set of full model and
> simplifications with different prefixes or with larger models with
> more simplifications. Any suggestions gratefully received.
Use do.call.
Something like
do.call("anova", c(as.list(objects(pattern="pop.div")), list(test="Chisq")))
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list