[R] Constrained OLS regression

David Barron mothsailor at googlemail.com
Wed Sep 27 13:07:32 CEST 2006


Have a look at the linear.hypothesis function in the car package.  For example:

> mod.duncan <- lm(prestige ~ income + education, data=Duncan)
>
> linear.hypothesis(mod.duncan, "income + education = 1")
Linear hypothesis test

Hypothesis:
income + education = 1

Model 1: prestige ~ income + education
Model 2: restricted model

  Res.Df    RSS Df Sum of Sq      F  Pr(>F)
1     42 7506.7
2     43 8045.2 -1    -538.5 3.0129 0.08994 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


On 27/09/06, Mesomeris, Spyros [CIR] <spyros.mesomeris at citigroup.com> wrote:
> Hello R helpers,
>
> I am trying to do a linear OLS regression of y on two variables x1 and
> x2. I want to constrain the coefficients of x1 and x2 to sum up to 1.
> and therefore run a constrained OLS. Can anybody help with this? (I have
> seen some answers to similar questions but it was not clear to me what I
> need to do) - I have tried the lm function with offset but I must not
> have used it properly.
>
> Thanks,
> Spyros
>
> ______________________________________________
> R-help at 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
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
=================================
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP



More information about the R-help mailing list