Hi Greg and others,

Thanks for your replies. Okay, I'm convinced that the offset is the best
approach and wonder if you might have a quick look at what I did.

Here's the original model containing the slope (0.56) that I'd like to test
if it's different from 1.0

>model1 <- glm(log(data$AB.obs+1,10) ~ log(data$SIZE,10) + data$YEAR)

and its coefficients:
                   Estimate Std. Error t value Pr(>|t|)
(Intercept)        -1.18253    0.09119 -12.967  < 2e-16 ***
log(data$SIZE, 10)  0.56001    0.02564  21.843  < 2e-16 ***
data$YEAR2008       0.16823    0.04366   3.853 0.000152 ***
data$YEAR2009       0.20299    0.04707   4.313 0.000024 ***

And here's the model with an offset term:

>model2 <- glm(log(data$AB.obs+1,10) ~ log(data$SIZE,10) +
offset(log(data$SIZE,10)) + data$YEAR)

and its coefficients:
                   Estimate Std. Error t value Pr(>|t|)
(Intercept)        -1.18253    0.09119 -12.967  < 2e-16 ***
log(data$SIZE, 10) -0.43999    0.02564 -17.162  < 2e-16 ***
data$YEAR2008       0.16823    0.04366   3.853 0.000152 ***
data$YEAR2009       0.20299    0.04707   4.313 0.000024 ***

So, if I understand correctly, the small P-value corresponding to the SIZE
coefficient in model2 indicates that the slope of 0.56 in model1 is
significantly different from 1.0, right?

If I may ask one more question: could I use the offset to test if the slope
of 0.56 is different from yet another value, e.g., 0.5?

Much appreciated.

Many thanks, Mark Na




On Wed, Apr 25, 2012 at 3:27 PM, Greg Snow <538...@gmail.com> wrote:

> Doesn't the p-value from using offset work for you?  if you really
> need a p-value.  The confint method is a quick and easy way to see if
> it is significantly different from 1 (see Rolf's response), but does
> not provide an exact p-value.  I guess you could do confidence
> intervals at different confidence levels until you find the level such
> that one of the limits is close enough to 1, but that seems like way
> to much work.  You could also compute the p-value by taking the slope
> minus 1 divided by the standard error and plug that into the pt
> function with the correct degrees of freedom.  You could even write a
> function to do that for you, but it still seems more work than adding
> the offset to the formula.
>
> On Tue, Apr 24, 2012 at 8:17 AM, Mark Na <mtb...@gmail.com> wrote:
> > Hi Greg. Thanks for your reply. Do you know if there is a way to use the
> > confint function to get a p-value on this test?
> >
> > Thanks, Mark
> >
> >
> >
> > On Mon, Apr 23, 2012 at 3:10 PM, Greg Snow <538...@gmail.com> wrote:
> >>
> >> 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 <mtb...@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@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.
> >> 538...@gmail.com
> >
> >
>
>
>
> --
> Gregory (Greg) L. Snow Ph.D.
> 538...@gmail.com
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to