[R] Functions in R like lincom and nlcom of Stata
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sun Dec 14 09:11:25 CET 2008
On Sat, 13 Dec 2008, Stas Kolenikov wrote:
> Those commands provide point estimates, standard errors and confidence
> intervals based on linear combination of parameters or
> linearization/delta-method, respectively. R's contrasts appear to be
> limited to a single factor and combinations that sum up to zero.
> I am too so used to this Stata's concept, I now think it's odd R does
> not seem to have it readily identifiable in two-three search commands.
> And I would not believe R does not have this functionality, it must be
> hiding somewhere! :))
It really depends on the class of models, e.g. se.contrast() applies to
aov models, including multistratum ones.
In general (as it is generic) vcov() provides a good starting point.
For linear models there are lots of approaches in contributed packages.
(E.g. gmodels::estimable, car::linear.hypothesis, the effects package.)
That said, I find myself needing this very rarely. Two general principles
1) set up models so the quantities of interest are parameters (and for
linearly-parametrized models, use C() and contrasts() to do so).
2) Interesting quantities from models are almost always based on
predictions, and hence most often only linear combinations of parameters
in linear models. Simulation is a good way to assess the uncertainty of
> On 12/13/08, David Winsemius <dwinsemius at comcast.net> wrote:
>> On Dec 12, 2008, at 11:14 AM, Marc Marí Dell'Olmo wrote:
>>> Hello all,
>>> Does anyone know if there exists any function in R that resembles the
>>> "lincom" and "nlcom" of STATA?. These functions computes point
>>> estimates, standard errors, significance levels, confidence intervals,
>>> etc. for linear and non linear combinations of previous estimated
>>> parameters. Down here you've got links to descriptions of the
>>> functions of STATA
>> I did not find a description of the mathematical operations that let me
>> understand exactly what lincom is doing, but suspect that you should be
>> looking at how R handles contrasts. The help pages reference ch 2 of
>> "Statistical Models in S". The search at the console prompt would be:
> Stas Kolenikov, also found at http://stas.kolenikov.name
> Small print: I use this email account for mailing lists only.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help