Tyler: To compare estimates of different slopes for Time by different
factor levels of Temperature you need to estimate a model that allows for
separate slopes.  What you've estimated is a model for just different
intercepts associated with Temperature factor but a common slope for Time.
 You probably want a model that allows for both separate intercepts and
slopes for Time across the Temperature factor levels.  Try lm(Percent ~
Time + Temperature + Time:Temperature); the Temperature effects will
describe differences in intercepts by factor levels and the
Time:Temperature interactions are differences in slopes (Time) across
factor levels.

Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  ca...@usgs.gov <brian_c...@usgs.gov>
tel:  970 226-9326



On Tue, Apr 23, 2013 at 12:02 PM, Hallman, Tyler <
tyler.hall...@oregonstate.edu> wrote:

> Hi Everyone,
>
> I am uncertain that I am writing the contrast statements correctly.
> Basically, I'm unsure when to use a -1 and a 1 when writing the contrasts.
> Specifically I am interested in comparing the slopes between different
> temperature regimes. Temperature is therefore a factor. Time and percent
> are numerical. Using the gmodels package I made the following model:
>
> m2<-lm(Percent~Time+Temperature, data=Hchrys.Temp);summary(m2)
>
> # results from m2
> Call:
> lm(formula = Percent ~ Time + Temperature, data = Hchrys.Temp)
>
> Residuals:
>       Min        1Q    Median        3Q       Max
> -0.098333 -0.031667 -0.003333  0.026667  0.101667
>
> Coefficients:
>                    Estimate Std. Error t value Pr(>|t|)
> (Intercept)      -0.0233333  0.0147504  -1.582 0.119413
> Time              0.0007639  0.0001774   4.306 6.91e-05 ***
> Temperature22:18  0.0133333  0.0170324   0.783 0.437088
> Temperature22:20  0.0133333  0.0170324   0.783 0.437088
> Temperature22:22  0.0666667  0.0170324   3.914 0.000252 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 0.04665 on 55 degrees of freedom
> Multiple R-squared: 0.3997, Adjusted R-squared: 0.356
> F-statistic: 9.154 on 4 and 55 DF,  p-value: 9.653e-06
>
> # I then built the contrasts based on the order of the coefficients above.
>
> cm1<-rbind("1:Temperature 20:20 v.22:22 " = c(0,0,0,0,1),
>                  "2:Temperature 22:18 v.22:22 " = c(0,0,-1,0,1),
>                  "3:Temperature 22:20 v.22:22 " = c(0,0,0,-1,1),
>                  "4:Temperature 20:20 v.22:20 " = c(0,0,0,1,0),
>                  "5:Temperature 22:18 v.22:20 " = c(0,0,-1,1,0),
>                  "6:Temperature 20:20 v.22:18 " = c(0,0,1,0,0))
>
> # To compare between them I used:
> estimable(m2,cm1)
>
> # The results of which are below.
>                                 Estimate Std. Error       t value DF
> Pr(>|t|)
> 1:Temperature 20:20 v.22:22   6.666667e-02 0.01703235  3.914120e+00 55
> 0.0002522632
> 2:Temperature 22:18 v.22:22   5.333333e-02 0.01703235  3.131296e+00 55
> 0.0027865530
> 3:Temperature 22:20 v.22:22   5.333333e-02 0.01703235  3.131296e+00 55
> 0.0027865530
> 4:Temperature 20:20 v.22:20   1.333333e-02 0.01703235  7.828240e-01 55
> 0.4370882317
> 5:Temperature 22:18 v.22:20  -3.469447e-17 0.01703235 -2.036975e-15 55
> 1.0000000000
> 6:Temperature 20:20 v.22:18   1.333333e-02 0.01703235  7.828240e-01 55
> 0.4370882317
>
> Did I write the contrasts correctly? And does this then indicate that the
> slope of 22:22 was significantly different from all others but none of the
> others were different?
>
> Help with comparing the slopes between these regressions would be
> wonderful.
>
> Cheers,
>
> -
> Tyler Hallman, M.S.
> Ph.D. Student
> The Robinson Lab
> Department of Fisheries and Wildlife
> Oregon State University Corvallis
>
>         [[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.
>
>

        [[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