setting parameters equal in lm
I don't know how it ties into the tools car gives you, but one (quick and dirty) way to do this is to simply regress on Y ~ aX2 + b(X1+X3) or in R code something like: lm(Y ~ X2 + I(X1+X3), data = data.set) which gives a linear model you can play around with. Note the I() function [that's the capital letter immediately preceding J] which tells R to interpret that term "AsIs" Hope this helps, Michael
On Mon, May 28, 2012 at 11:14 PM, Dustin Fife <fife.dustin at gmail.com> wrote:
Forgive me if this is a trivial question, but I couldn't find it an answer
in former forums. I'm trying to reproduce some SAS results where they set
two parameters equal. For example:
y = b1X1 + b2X2 + b1X3
Notice that the variables X1 and X3 both have the same slope and the
intercept has been removed. How do I get an estimate of this regression
model? I know how to remove the intercept ("-1" somewhere after the tilde).
But how about setting parameters equal? I have used the car package to set
up linear hypotheses:
X1 = rnorm(20, 10, 5); X2 = rnorm(20, 10, 5); X3 = rnorm(20, 10, 5)
Y = .5*X1 + 3*X2 + .5*X3 + rnorm(20, 0, 15)
data.set = data.frame(cbind(X1, X2, X3, Y))
linMod = lm(Y~X1 + X2 + X3, data=data.set)
require(car)
linearHypothesis(linMod, c("(Intercept)=0", "X1-X3=0"))
(forgive the unconventional use of the equal sign....old habit).
Unfortunately, the linearHypothesis is always compared to a full model
(where the parameters are freely estimated). I want to have an ANOVA
summary table for the reduced model. Any ideas? Thanks in advance for the
help!
--
Dustin Fife
PhD Student
Quantitative Psychology
University of Oklahoma
? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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.