[R] How to test if a slope is different than 1?

Greg Snow 538280 at gmail.com
Mon Apr 23 23:10:52 CEST 2012


One option is to subtract the continuous variable from y before doing
the regression (this works with any regression package/function).  The
probably better way in R is to use the 'offset' function:

formula = I(log(data$AB.obs + 1, 10)-log(data$SIZE,10)) ~
log(data$SIZE, 10) + data$Y
formula = log(data$AB.obs + 1) ~ offset( log(data$SIZE,10) ) +
log(data$SIZE,10) + data$Y

Or you can use a function like 'confint' to find the confidence
interval for the slope and see if 1 is in the interval.

On Mon, Apr 23, 2012 at 12:11 PM, Mark Na <mtb954 at gmail.com> wrote:
> Dear R-helpers,
>
> I would like to test if the slope corresponding to a continuous variable in
> my model (summary below) is different than one.
>
> I would appreciate any ideas for how I could do this in R, after having
> specified and run this model?
>
> Many thanks,
>
> Mark Na
>
>
>
> Call:
> lm(formula = log(data$AB.obs + 1, 10) ~ log(data$SIZE, 10) +
>   data$Y)
>
> Residuals:
>    Min       1Q   Median       3Q      Max
> -0.94368 -0.13870  0.04398  0.17825  0.63365
>
> Coefficients:
>                  Estimate Std. Error t value  Pr(>|t|)
> (Intercept)        -1.18282    0.09120 -12.970   < 2e-16 ***
> log(data$SIZE, 10)  0.56009    0.02564  21.846   < 2e-16 ***
> data$Y2008          0.16825    0.04366   3.854  0.000151 ***
> data$Y2009          0.20310    0.04707   4.315 0.0000238 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 0.2793 on 228 degrees of freedom
> Multiple R-squared: 0.6768,     Adjusted R-squared: 0.6726
> F-statistic: 159.2 on 3 and 228 DF,  p-value: < 2.2e-16
>
>        [[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.
>



-- 
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com



More information about the R-help mailing list