Hello I want to compare the slope (let's say 'b') of a linear model obtained with lm() to a theoretical value (let's say 'th'). To do so, I think I should compute a 't value' using something like : (b - 'th')/standard.deviation(b) and then look at the p-value of this computed t. I don't understand how to do this in a simple way, just using lm() outputs for example. I'm sorry of such a naive/newbie question, and thank you so much for taking time to answer. Fred -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi Fred, Maybe this helps My.lm<-summary(lm(y~x)) My.lm$coefficients It gives you the parameters estimates with t and p-values. Have a look at names(my.lmmodel) and names(summary(my.lmmodel) If you only need to calculate the p-value having t then p <- 2*(1-pt(abs(t),df=your.df))) -----Original Message----- From: Fred JEAN [mailto:frederic.jean at univ-brest.fr] Sent: Freitag, 22. November 2002 22:09 To: r-help at stat.math.ethz.ch Subject: [R] simple test on slope of lm() Hello I want to compare the slope (let's say 'b') of a linear model obtained with lm() to a theoretical value (let's say 'th'). To do so, I think I should compute a 't value' using something like : (b - 'th')/standard.deviation(b) and then look at the p-value of this computed t. I don't understand how to do this in a simple way, just using lm() outputs for example. I'm sorry of such a naive/newbie question, and thank you so much for taking time to answer. Fred -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._._._ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello, To test the slope of your linear model against an arbitrary value, you can use lm() directly with a little trick. Let b1 be the value of the slope you want to test your model against, then use lm(y-b1*x~x). The significance test of the slope for this lm model gives the answer you need. > x <- rnorm(10) > y <- 2*x + rnorm(10) > lm(y~x) > lm(y-2*x~x) Hope this helped, Yves Brostaux. At 04:01 23/11/02, you wrote:>Date: Fri, 22 Nov 2002 22:08:43 +0100 >From: Fred JEAN <frederic.jean at univ-brest.fr> >Subject: [R] simple test on slope of lm() > >Hello > >I want to compare the slope (let's say 'b') of a linear model obtained >with lm() to a theoretical value (let's say 'th'). > >To do so, I think I should compute a 't value' using >something like : > >(b - 'th')/standard.deviation(b) > >and then look at the p-value of this computed t. > >I don't understand how to do this in a simple way, just using lm() >outputs for example. > >I'm sorry of such a naive/newbie question, and thank you so much for >taking time to answer. > >Fred-- Ir. Yves Brostaux - Statistics and Computer Science Dpt. Gembloux Agricultural University 8, avenue de la Facult? B-5030 Gembloux (Belgium) T?l : +32 (0)81 62 24 69 E-mail : brostaux.y at fsagx.ac.be Web : http://www.fsagx.ac.be/si/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
The gregmisc library contains a function 'glh.test' for testing general linear hypotheses which can be used to perform this test:> x <- rnorm(100) > y <- x + rnorm(100) > model <- lm(y ~ x) > modelCall: lm(formula = y ~ x) Coefficients: (Intercept) x -0.1031 1.0172> library(gregmisc)Loading required package: MASS Attaching package `gregmisc': The following object(s) are masked from package:base : lowess> # test: 0*b0 + 1*b1 = 1 > glh.test( model, cm=c(0,1), d=1)Test of General Linear Hypothesis Call: glh.test(reg = model, cm = c(0, 1), d = 1) F = 0.0285, df1 = 1, df2 = 98, p-value = 0.8663 -Greg> -----Original Message----- > From: Fred JEAN [mailto:frederic.jean at univ-brest.fr] > Sent: Friday, November 22, 2002 4:09 PM > To: r-help at stat.math.ethz.ch > Subject: [R] simple test on slope of lm() > > > Hello > > I want to compare the slope (let's say 'b') of a linear model > obtained > with lm() to a theoretical value (let's say 'th'). > > To do so, I think I should compute a 't value' using > something like : > > (b - 'th')/standard.deviation(b) > > and then look at the p-value of this computed t. > > I don't understand how to do this in a simple way, just using lm() > outputs for example. > > I'm sorry of such a naive/newbie question, and thank you so much for > taking time to answer. > > Fred > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. > -.-.-.-.-.-.-.-.- > r-help mailing list -- Read > http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: > r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _._._._._._._._._ >LEGAL NOTICE Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._