From: Douglas Bates <bates_at_stat.wisc.edu>

Date: Wed 10 May 2006 - 05:17:01 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed May 10 05:23:18 2006

Date: Wed 10 May 2006 - 05:17:01 EST

On 5/9/06, Andrew Gelman <gelman@stat.columbia.edu> wrote:

> Hi, all. In setting up my package for post-processing regression

*> models, I am trying to use standard notation as much as possible: thus,
**> I use coef() to access estimated coefficients. I wrote a function
**> called se.coef() to grab standard errors, and se.fixef() and se.ranef()
**> to grab se's from coefficients estimated from lmer().
*

I too have difficulty in coming up with reasonable names for generics, especially for lmer objects. I'm not particularly pleased with the value of the coef method for that class in that it is well-defined for models with nested grouping factors but not for models with crossed or partially crossed grouping factors for the random effects. One suggestion (I believe due to Harold Doran) is to check on whether the grouping factors are nested and throw an error if they are not.

Regarding the se.fixef I would use the vcov extractor instead in the form

sqrt(diag(vcov(lmerModel)))

That's enough of a self-explanatory "one liner" that I wouldn't create a special generic. Another approach that should work but currently doesn't is to use

coef(summary(lmerModel))

In general we should have that return the table of coefficients and their standard errors, etc. and I could modify the package to create this behavior. Alternatively, I could create methods for the summary.lmer class so that

fixef(summary(lmerModel))

returns the summary table of the fixed effects and

ranef(summary(lmerModel))

returns the summary table for the random effects.

In general I would prefer to compose extractors to get the desired effect instead of creating new generics and associated methods. There are far too many function names in R to remember already.

> I also need a function to access sigma-hat (the residual sd of the

*> regression). I've called this function sigma.hat(), but I'm open to
**> using a better name if there's something more standard.
*

About the best I can think of is to make 'sd' a generic and create methods for that.

> I also have a function called sim() that makes simulations using lm() or

*> glm() output (based on the curvature of the likelihood function or, to
**> put it another way, approximate Bayesian inference assuming a flat prior
**> distribution). sim() returns a list: with two components: (1) beta, a
**> matrix of simulated coefficients (with dimension n.sims by k), and (2)
**> sigma, a vector of simulated sigma's (with length n.sims).
*

There is already a "simulate" generic. One approach would be to extend the argument list for that generic.

> I'll be doing more, but these are the basics for now. I need to be able

*> to pull these objects out as necessary. And I just was wondering if
**> anyone had suggested names for the functions that are more consistent
**> with R naming conventions.
*

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed May 10 05:23:18 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Wed 10 May 2006 - 06:10:04 EST.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*