[R-sig-ME] Calculating fixed effect contrasts with log-transformed data
Gus Jespersen
jesper at u.washington.edu
Tue Jul 17 21:02:42 CEST 2012
Thank you Thierry,
I have looked through the glht function in multcomp, and have two
further questions:
(1) For the lmer output below, I would like to go through and
calculate a 95% CI for the difference between each "Treatment" and
"Control" fixed effect. Based on my reading of the glht instructions,
this should look like:
> glht(Mod.NO3.1.1, linfct=c("sitettMossAddition Treatment - sitettMossAddition Control=0"))
Yet I get the following error message:
Error in parse(text = ex[i]) : <text>:1:20: unexpected symbol
1: sitettMossAddition Treatment
^
Any ideas on what I'm doing wrong here?
(2) As you can see, I am working with a log10 transformed response
variable. I'd like to stay with this for homog. of variance reasons,
and for reporting the "Treatment -Control" CI previously mentioned,
I'd like to report the backtransformed limits of the CI. At what
point in this process should the back-transformation happen? When
attempting this calculation without glht, I am uncertain of where in
the process to back-transform as well. I had been hoping to simply
use 10^ for each fixed effect and its SE, as well as each element of
the vcov matrix, but I fear I am overlooking some basic math here.
Finally, I have pasted my data below the model output, in case this is
helpful.
Thank you,
Gus
### Model Code ###
Mod.NO3.1.1<-lmer(NO3Nyearone ~ 1 + sitett +(1 | pr), data=data.file.final)
Mod.NO3.1.2<-lmer(log10(NO3Nyearone)~ 1 + (1 | pr), data=data.file.final)
anova(Mod.NO3.1.1,Mod.NO3.1.2)
Mod.NO3.1.1
### Output ###
Data: data.file.final
Models:
Mod.NO3.1.2: log10(NO3Nyearone) ~ 1 + (1 | pr)
Mod.NO3.1.1: log10(NO3Nyearone) ~ 1 + sitett + (1 | pr)
Df AIC BIC logLik Chisq Chi Df Pr(>Chisq)
Mod.NO3.1.2 3 99.830 108.59 -46.915
Mod.NO3.1.1 14 74.329 115.21 -23.165 47.501 11 1.752e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Linear mixed model fit by REML
Formula: log10(NO3Nyearone) ~ 1 + sitett + (1 | pr)
Data: data.file.final
AIC BIC logLik deviance REMLdev
110.9 151.8 -41.46 46.33 82.92
Random effects:
Groups Name Variance Std.Dev.
pr (Intercept) 0.0029239 0.054073
Residual 0.0871127 0.295149
Number of obs: 137, groups: pr, 72
Fixed effects:
Estimate Std. Error t value
(Intercept) 1.24011 0.09047 13.708
sitettLepAddition Treatment -0.03859 0.12329 -0.313
sitettMossAddition Control 0.07747 0.13110 0.591
sitettMossAddition Treatment 0.13940 0.12794 1.090
sitettMossRemoval Control -0.36994 0.12525 -2.954
sitettMossRemoval Treatment -0.25789 0.12525 -2.059
sitettSaddle Control -0.33039 0.12525 -2.638
sitettSaddle Treatment -0.46379 0.12794 -3.625
sitettToeAdditions Control -0.17356 0.12525 -1.386
sitettToeAdditions Treatment -0.33236 0.13110 -2.535
sitettToeRemoval Control -0.38744 0.12525 -3.093
sitettToeRemoval Treatment -0.44006 0.12525 -3.513
Correlation of Fixed Effects:
(Intr) sttLAT sttMAC sttMAT sttMRC sttMRT stttSC stttST
sttTAC sttTAT sttTRC
stttLpAddtT -0.712
stttMssAddC -0.690 0.491
stttMssAddT -0.707 0.503 0.502
stttMssRmvC -0.722 0.514 0.498 0.511
stttMssRmvT -0.722 0.514 0.498 0.511 0.537
stttSddlCnt -0.722 0.514 0.498 0.511 0.522 0.522
stttSddlTrt -0.707 0.503 0.488 0.500 0.511 0.511 0.526
stttTAddtnC -0.722 0.514 0.498 0.511 0.522 0.522 0.522 0.511
stttTAddtnT -0.690 0.491 0.476 0.488 0.498 0.498 0.498 0.488
0.513
stttTRmvlCn -0.722 0.514 0.498 0.511 0.522 0.522 0.522 0.511
0.522 0.498
stttTRmvlTr -0.722 0.514 0.498 0.511 0.522 0.522 0.522 0.511
0.522 0.498 0.537
##### Data ######
PlotID Site pr tt sitett NO3Nyearone
3156 LepAddition LeprariaAdditionone Control LepAddition Control 35
3155 LepAddition LeprariaAdditionone Treatment LepAddition Treatment 105.6
3161 LepAddition LeprariaAdditionfour Treatment LepAddition Treatment 44.8
3297 LepAddition LeprariaAdditionseven Control LepAddition Control 40.6
3158 LepAddition LeprariaAdditiontwo Control LepAddition Control 26.4
3162 LepAddition LeprariaAdditionfour Control LepAddition Control 19.6
3293 LepAddition LeprariaAdditioneight Control LepAddition Control 28.2
3157 LepAddition LeprariaAdditiontwo Treatment LepAddition Treatment 21.8
2740 LepAddition LeprariaAdditionthree Control LepAddition Control 21.8
2745 LepAddition LeprariaAdditionnine Treatment LepAddition Treatment 20.2
2755 LepAddition LeprariaAdditionsix Treatment LepAddition Treatment 7.8
3284 LepAddition LeprariaAdditiontwelve Treatment LepAddition Treatment 16.4
2749 LepAddition LeprariaAdditionfive Control LepAddition Control 14.6
2744 LepAddition LeprariaAdditionnine Control LepAddition Control 13
2759 LepAddition LeprariaAdditioneleven Treatment LepAddition Treatment 7.4
2758 LepAddition LeprariaAdditioneleven Control LepAddition Control 7.4
3292 LepAddition LeprariaAdditioneight Treatment LepAddition Treatment 12.8
3296 LepAddition LeprariaAdditionseven Treatment LepAddition Treatment 9.6
2748 LepAddition LeprariaAdditionfive Treatment LepAddition Treatment 12.6
3294 LepAddition LeprariaAdditionthirteen Treatment LepAddition Treatment 7.8
3285 LepAddition LeprariaAdditiontwelve Control LepAddition Control 8.4
2754 LepAddition LeprariaAdditionsix Control LepAddition Control 8.4
2741 LepAddition LeprariaAdditionthree Treatment LepAddition Treatment 11
3289 MossAddition MossAddthree Treatment MossAddition Treatment 63.8
2751 MossAddition MossAddsix Control MossAddition Control 46.8
3286 MossAddition MossAddthree Control MossAddition Control 61.8
3288 MossAddition MossAddeleven Treatment MossAddition Treatment 59.4
2747 MossAddition MossAddseven Treatment MossAddition Treatment 54.3
2752 MossAddition MossAddeight Treatment MossAddition Treatment 20.6
3280 MossAddition MossAddtwo Control MossAddition Control 31.8
3163 MossAddition MossAddtwelve Control MossAddition Control 37.8
2750 MossAddition MossAddsix Treatment MossAddition Treatment 30.8
2743 MossAddition MossAddfive Treatment MossAddition Treatment 25
3291 MossAddition MossAddeleven Control MossAddition Control 20.2
3299 MossAddition MossAddone Control MossAddition Control 25
3281 MossAddition MossAddtwo Treatment MossAddition Treatment 16.3
2757 MossAddition MossAddnine Control MossAddition Control 14.8
2753 MossAddition MossAddeight Control MossAddition Control 21
3164 MossAddition MossAddtwelve Treatment MossAddition Treatment 18
3160 MossAddition MossAddfour Treatment MossAddition Treatment 17.6
2742 MossAddition MossAddfive Control MossAddition Control 18.8
2756 MossAddition MossAddnine Treatment MossAddition Treatment 11.6
3287 MossAddition MossAddten Control MossAddition Control 10.8
3290 MossAddition MossAddten Treatment MossAddition Treatment 7.6
2746 MossAddition MossAddseven Control MossAddition Control 4.4
3242 MossRemoval MossRemone Control MossRemoval Control 40.6
3245 MossRemoval MossRemtwo Treatment MossRemoval Treatment 24.6
3253 MossRemoval MossRemtwelve Control MossRemoval Control 7.6
3250 MossRemoval MossRemnine Treatment MossRemoval Treatment 11
3240 MossRemoval MossRemseven Treatment MossRemoval Treatment 6.6
3257 MossRemoval MossRemfive Control MossRemoval Control 7.4
3244 MossRemoval MossRemtwo Control MossRemoval Control 9.2
3252 MossRemoval MossRemtwelve Treatment MossRemoval Treatment 6.8
3254 MossRemoval MossRemsix Treatment MossRemoval Treatment 17.4
3241 MossRemoval MossRemseven Control MossRemoval Control 9
3255 MossRemoval MossRemsix Control MossRemoval Control 6
2687 MossRemoval MossRemten Treatment MossRemoval Treatment 11.8
3246 MossRemoval MossRemthree Control MossRemoval Control 11
3243 MossRemoval MossRemone Treatment MossRemoval Treatment 10.2
3259 MossRemoval MossRemfour Treatment MossRemoval Treatment 9
3247 MossRemoval MossRemthree Treatment MossRemoval Treatment 6.8
3251 MossRemoval MossRemnine Control MossRemoval Control 8.4
2684 MossRemoval MossRemeleven Treatment MossRemoval Treatment 7.2
3248 MossRemoval MossRemeight Treatment MossRemoval Treatment 7
3249 MossRemoval MossRemeight Control MossRemoval Control 10
3258 MossRemoval MossRemfour Control MossRemoval Control 8.8
3256 MossRemoval MossRemfive Treatment MossRemoval Treatment 7.8
2686 MossRemoval MossRemten Control MossRemoval Control 1
2685 MossRemoval MossRemeleven Control MossRemoval Control 3
2999 Saddle LeprariaRemovalnine Treatment Saddle Treatment 21.8
2998 Saddle LeprariaRemovalnine Control Saddle Control 12
2956 Saddle LeprariaRemovaltwelve Control Saddle Control 11.6
2485 Saddle LeprariaRemovalthree Control Saddle Control 13.4
2489 Saddle LeprariaRemovalten Control Saddle Control 3
2497 Saddle LeprariaRemovalsix Control Saddle Control 13.2
2487 Saddle LeprariaRemovalten Treatment Saddle Treatment 3.4
2958 Saddle LeprariaRemovaleleven Treatment Saddle Treatment 7.4
2491 Saddle LeprariaRemovalone Treatment Saddle Treatment 12.2
2483 Saddle LeprariaRemovalfour Control Saddle Control 16.4
2484 Saddle LeprariaRemovalthree Treatment Saddle Treatment 14.4
2498 Saddle LeprariaRemovalseven Control Saddle Control 9.8
2493 Saddle LeprariaRemovaltwo Control Saddle Control 8.6
2481 Saddle LeprariaRemovaleight Treatment Saddle Treatment 10.8
2480 Saddle LeprariaRemovaleight Control Saddle Control 5.4
2959 Saddle LeprariaRemovaleleven Control Saddle Control 6.6
2496 Saddle LeprariaRemovalsix Treatment Saddle Treatment 3.6
2494 Saddle LeprariaRemovalfive Control Saddle Control 4.2
2490 Saddle LeprariaRemovalone Control Saddle Control 5.4
2482 Saddle LeprariaRemovalfour Treatment Saddle Treatment 3.2
2495 Saddle LeprariaRemovalfive Treatment Saddle Treatment 3.4
2499 Saddle LeprariaRemovalseven Treatment Saddle Treatment 3
2492 Saddle LeprariaRemovaltwo Treatment Saddle Treatment 2.8
2577 ToeAdditions FlavocetrariaAdditiontwelve Control ToeAdditions Control 121.4
2581 ToeAdditions FlavocetrariaAdditionone Control ToeAdditions Control 17.2
2576 ToeAdditions FlavocetrariaAdditionfour Control ToeAdditions Control 20.8
2568 ToeAdditions FlavocetrariaAdditiontwo Control ToeAdditions Control 17.6
2580 ToeAdditions FlavocetrariaAdditionthree Control ToeAdditions Control 18.4
2572 ToeAdditions FlavocetrariaAdditioneight Treatment ToeAdditions
Treatment 14.6
2573 ToeAdditions FlavocetrariaAdditionfour Treatment ToeAdditions Treatment 12
2571 ToeAdditions FlavocetrariaAdditionfive Control ToeAdditions Control 10.8
2574 ToeAdditions FlavocetrariaAdditionseven Treatment ToeAdditions
Treatment 13.6
2588 ToeAdditions FlavocetrariaAdditiontwo Treatment ToeAdditions Treatment 10.2
2575 ToeAdditions FlavocetrariaAdditionsix Control ToeAdditions Control 11.8
2579 ToeAdditions FlavocetrariaAdditionnine Treatment ToeAdditions
Treatment 13.8
2584 ToeAdditions FlavocetrariaAdditionseven Control ToeAdditions Control 8.6
2582 ToeAdditions FlavocetrariaAdditionten Control ToeAdditions Control 10
2569 ToeAdditions FlavocetrariaAdditionsix Treatment ToeAdditions Treatment 8.6
2583 ToeAdditions FlavocetrariaAdditionone Treatment ToeAdditions Treatment 7.2
2578 ToeAdditions FlavocetrariaAdditioneleven Control ToeAdditions Control 10.2
2570 ToeAdditions FlavocetrariaAdditionfive Treatment ToeAdditions Treatment 9.8
2585 ToeAdditions FlavocetrariaAdditionthree Treatment ToeAdditions
Treatment 6.6
2589 ToeAdditions FlavocetrariaAdditionten Treatment ToeAdditions Treatment 4
2683 ToeAdditions FlavocetrariaAdditionnine Control ToeAdditions Control 5
2586 ToeAdditions FlavocetrariaAdditiontwelve Treatment ToeAdditions
Treatment 6.2
2682 ToeAdditions FlavocetrariaAdditioneight Control ToeAdditions Control 0.8
2681 ToeAdditions FlavocetrariaAdditioneleven Treatment ToeAdditions Treatment 5
2986 ToeRemoval FlavocetrariaRemovalfive Treatment ToeRemoval Treatment 16.8
2991 ToeRemoval FlavocetrariaRemovalfour Control ToeRemoval Control 16.6
2983 ToeRemoval FlavocetrariaRemovaltwo Control ToeRemoval Control 9.6
2994 ToeRemoval FlavocetrariaRemovalnine Control ToeRemoval Control 7.8
2989 ToeRemoval FlavocetrariaRemovalthree Treatment ToeRemoval Treatment 7.2
2796 ToeRemoval FlavocetrariaRemovaleight Control ToeRemoval Control 9.2
2982 ToeRemoval FlavocetrariaRemovaltwo Treatment ToeRemoval Treatment 7.2
2985 ToeRemoval FlavocetrariaRemovalone Treatment ToeRemoval Treatment 6.8
2984 ToeRemoval FlavocetrariaRemovalone Control ToeRemoval Control 2.6
2799 ToeRemoval FlavocetrariaRemovalten Control ToeRemoval Control 8
2797 ToeRemoval FlavocetrariaRemovaleight Treatment ToeRemoval Treatment 9.4
2992 ToeRemoval FlavocetrariaRemovalsix Control ToeRemoval Control 8.4
2981 ToeRemoval FlavocetrariaRemovaltwelve Control ToeRemoval Control 7.8
2996 ToeRemoval FlavocetrariaRemovalseven Control ToeRemoval Control 6.6
2980 ToeRemoval FlavocetrariaRemovaltwelve Treatment ToeRemoval Treatment 7.8
2987 ToeRemoval FlavocetrariaRemovalfive Control ToeRemoval Control 6.4
2988 ToeRemoval FlavocetrariaRemovalthree Control ToeRemoval Control 5.4
2990 ToeRemoval FlavocetrariaRemovalfour Treatment ToeRemoval Treatment 6
2993 ToeRemoval FlavocetrariaRemovalsix Treatment ToeRemoval Treatment 4.2
2689 ToeRemoval FlavocetrariaRemovaleleven Control ToeRemoval Control 4.8
2997 ToeRemoval FlavocetrariaRemovalseven Treatment ToeRemoval Treatment 4.6
2798 ToeRemoval FlavocetrariaRemovalten Treatment ToeRemoval Treatment 6
2688 ToeRemoval FlavocetrariaRemovaleleven Treatment ToeRemoval Treatment 4.4
2995 ToeRemoval FlavocetrariaRemovalnine Treatment ToeRemoval Treatment 3
On Mon, Jul 16, 2012 at 1:53 AM, ONKELINX, Thierry
<Thierry.ONKELINX at inbo.be> wrote:
> Dear Gus,
>
> Have a look at glht() from the multcomp package. It allows you to define the contrasts that you are interested in.
>
> Best regards,
>
> Thierry
>
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
> team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
> Kliniekstraat 25
> 1070 Anderlecht
> Belgium
> + 32 2 525 02 51
> + 32 54 43 61 85
> Thierry.Onkelinx at inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> -----Oorspronkelijk bericht-----
> Van: r-sig-mixed-models-bounces at r-project.org [mailto:r-sig-mixed-models-bounces at r-project.org] Namens Gus Jespersen
> Verzonden: vrijdag 13 juli 2012 20:33
> Aan: r-sig-mixed-models at r-project.org
> Onderwerp: [R-sig-ME] Calculating fixed effect contrasts with log-transformed data
>
> Greetings,
> I doubt this is a particularly interesting question for you mixed model gurus, but here goes. As you can see in the output below, I have a model with twelve fixed effect parameters. I am interested in each of the "Treatment" vs. "Control" comparisons for each "site"(in each fixed effect parameter name, these are specified by the text immediately following "sitett"). To produce a 95% CI for such a comparison I was advised to take two steps:
>
> (1) Subtract the Control parameter estimate from the Treatment parameter estimate for each site.
> (2) Compute the SE for this comparison via: sqrt( var(treatment) +
> var(control) - 2*cov(treatmentt,control)). To get these values I am using the vcov matrix for the model.
>
> When I move to log10-transformed data, I am thinking I should backtransform the fixed effects and SE's before moving ahead with the Control-Treatment comparisons. However, the calculations become more problematic as ( var(treatment) + var(control) -
> 2*cov(treatmentt,control)) is consistently negative. I am uncertain on how to proceed here. Any advice would be much appreciated.
>
> Thank you,
> Gus
>
> Data: data.file.final
> Models:
> Mod.NO3.1.2: NO3Nyearone ~ 1 + (1 | pr)
> Mod.NO3.1.1: NO3Nyearone ~ 1 + sitett + (1 | pr)
> Df AIC BIC logLik Chisq Chi Df Pr(>Chisq)
> Mod.NO3.1.2 3 1163.5 1172.2 -578.72
> Mod.NO3.1.1 14 1155.8 1196.7 -563.90 29.637 11 0.001806 **
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Linear mixed model fit by REML
> Formula: NO3Nyearone ~ 1 + sitett + (1 | pr)
> Data: data.file.final
> AIC BIC logLik deviance REMLdev
> 1098 1139 -534.8 1128 1070
> Random effects:
> Groups Name Variance Std.Dev.
> pr (Intercept) 33.348 5.7747
> Residual 210.115 14.4954
> Number of obs: 137, groups: pr, 72
>
> Fixed effects:
> Estimate Std. Error t value
> (Intercept) 20.118 4.701 4.280
> sitettLepAddition Treatment 3.032 6.069 0.500
> sitettMossAddition Control 5.677 6.809 0.834
> sitettMossAddition Treatment 9.418 6.648 1.417
> sitettMossRemoval Control -9.951 6.510 -1.529
> sitettMossRemoval Treatment -9.601 6.510 -1.475
> sitettSaddle Control -10.985 6.510 -1.687
> sitettSaddle Treatment -12.269 6.648 -1.846
> sitettToeAdditions Control 0.932 6.510 0.143
> sitettToeAdditions Treatment -11.678 6.809 -1.715
> sitettToeRemoval Control -12.351 6.510 -1.897
> sitettToeRemoval Treatment -13.168 6.510 -2.023
>
>
>
> --
> R. Gus Jespersen
> PhD Candidate
> College of Forest Resources
> University of Washington
> Box 352100
> Seattle, WA 98195-2100
> (206) 543-5777
> jesper at u.washington.edu
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> * * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
> The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.
--
R. Gus Jespersen
PhD Candidate
College of Forest Resources
University of Washington
Box 352100
Seattle, WA 98195-2100
(206) 543-5777
jesper at u.washington.edu
More information about the R-sig-mixed-models
mailing list