Christoph Lehmann
2004-Aug-30 10:14 UTC
[R] after lm-fit: equality of two regression coefficients test
Hi Let's assume, we have a multiple linear regression, such as the one using the Scottish hills data (MASS, data(hills)): one dependent variable: time two independent var (metric): dist, climb if I am interested, after (!) fitting a lm: my. lm <- lm(time ~ dist + climb, data = hills) in the equivalence (or non-equivalence) of the two predictors "dist" and "climb": H0: dist = climb Is there any function in R, which lets me calculate this, in just giving the lm-object "my.lm" and e.g. a vector such as c(1, -1), operationalizing the hypothesis H0: t(c(1, -1)) %*% c(dist, climb) = 0 ? many thanks Cheers! Christoph
Prof Brian Ripley
2004-Aug-30 10:47 UTC
[R] after lm-fit: equality of two regression coefficients test
On Mon, 30 Aug 2004, Christoph Lehmann wrote:> Hi > > Let's assume, we have a multiple linear regression, such as the one > using the Scottish hills data (MASS, data(hills)): > > one dependent variable: time > two independent var (metric): dist, climb > > if I am interested, after (!) fitting a lm: > > my. lm <- lm(time ~ dist + climb, data = hills) > > in the equivalence (or non-equivalence) of the two predictors "dist" and > "climb": > > H0: dist = climbI think you intend to ask if the *coefficients* in the fit should be equal, which is nonsense in this example of course.> Is there any function in R, which lets me calculate this, in just giving > the lm-object "my.lm" and e.g. a vector such as c(1, -1), > operationalizing the hypothesis H0: t(c(1, -1)) %*% c(dist, climb) = 0 ?library(car) ?linear.hypothesis -- 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
Vito Muggeo
2004-Aug-30 11:01 UTC
R: [R] after lm-fit: equality of two regression coefficients test
Hi Christoph, If you are interested in testing for b1=b2 in a regression model, say y=b0+b1*x1+b2*x2+e you can compare the two models o1 and o2 o1<-lm(y~x1+x2) o2<-lm(y~I(x1+x2)) best, vito ----- Original Message ----- From: Christoph Lehmann <christoph.lehmann at gmx.ch> To: <R-help at stat.math.ethz.ch> Sent: Monday, August 30, 2004 12:14 PM Subject: [R] after lm-fit: equality of two regression coefficients test> Hi > > Let's assume, we have a multiple linear regression, such as the one > using the Scottish hills data (MASS, data(hills)): > > one dependent variable: time > two independent var (metric): dist, climb > > if I am interested, after (!) fitting a lm: > > my. lm <- lm(time ~ dist + climb, data = hills) > > in the equivalence (or non-equivalence) of the two predictors "dist" and > "climb": > > H0: dist = climb > > Is there any function in R, which lets me calculate this, in just giving > the lm-object "my.lm" and e.g. a vector such as c(1, -1), > operationalizing the hypothesis H0: t(c(1, -1)) %*% c(dist, climb) = 0 ? > > many thanks > > Cheers! > > Christoph > > ______________________________________________ > 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