Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Calculate and Test Adjusted Mean Differences
From
Steve Samuels <[email protected]>
To
[email protected]
Subject
Re: st: Calculate and Test Adjusted Mean Differences
Date
Thu, 27 Sep 2012 17:43:51 -0400
On Sep 27, 2012, at 2:26 PM, Elizabeth Prezio wrote:
> "I thought about using lincom, but decided that was incorrect because I
> don't want to subtract coefficients"
Yes you do, Elizabeth.
Your notion that you can do independent sample t-tests is wrong. You
don't have independent estimates of marginal means in the two groups.
The estimates are correlated because the model specified main effects of
the other predictors. (Estimates of variance components are also
shared).
-margins- with a -post- option will put the marginal means into e(b), a
vector of "coefficients". You can use -lincom- on these. After the
(first) -margins- command, immediately run
*******************
margins, coeflegend
*******************
This will show you the names of the coefficients to give -lincom-.
To stay on the good side of many people here, I also suggest that you
not spell "Stata" as "STATA". See the FAQ. Section 4.1.
Steve
First I apologize if this question is too simple for statalist. I have read
all the STATA help and I have been through the statalist archives before
posting this question and I am need of some advice/help. My advisors have
been unable to help me.
I am using xtmixed to obtain adjusted mean values of hemoglobin A1c repeated
measures. I used margins to obtain adjusted means. What I want to do is
calculate the mean change (time 5 -time 1) and compare this mean change
between the two patient groups (patgrp) using an independent samples ttest.
Here is my output followed by additional comments to more thoroughly explain
what I am trying to do:
. xtmixed test i.patgrp##i.time duration blmeds medchange hba1_bl || id:
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log likelihood = -1369.6252
Iteration 1: log likelihood = -1369.6252
Computing standard errors:
Mixed-effects ML regression Number of obs =
790
Group variable: id Number of groups =
159
Obs per group: min =
4
avg =
5.0
max =
5
Wald chi2(13) =
367.58
Log likelihood = -1369.6252 Prob > chi2 =
0.0000
----------------------------------------------------------------------------
--
test | Coef. Std. Err. z P>|z| [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
1.patgrp | .0416097 .2301982 0.18 0.857 -.4095705
.4927899
|
time |
2 | -.75 .1942519 -3.86 0.000 -1.130727
-.3692734
3 | -.6725 .1942519 -3.46 0.001 -1.053227
-.2917733
4 | -.72875 .1942519 -3.75 0.000 -1.109477
-.3480233
5 | -.9198457 .1956848 -4.70 0.000 -1.303381
-.5363106
|
patgrp#time |
1 2 | -.1601266 .2755816 -0.58 0.561 -.7002566
.3800034
1 3 | -.4426899 .2755816 -1.61 0.108 -.98282
.0974401
1 4 | -.72693 .2766192 -2.63 0.009 -1.269094
-.1847663
1 5 | -.6758705 .2771046 -2.44 0.015 -1.218985
-.1327556
|
duration | .0376279 .0149067 2.52 0.012 .0084113
.0668446
blmeds | .3366165 .1089313 3.09 0.002 .1231152
.5501179
medchange | .3238106 .0687527 4.71 0.000 .1890578
.4585633
hba1_bl | .4035153 .0386847 10.43 0.000 .3276947
.4793358
_cons | 4.234591 .3608965 11.73 0.000 3.527247
4.941936
----------------------------------------------------------------------------
--
----------------------------------------------------------------------------
--
Random-effects Parameters | Estimate Std. Err. [95% Conf.
Interval]
-----------------------------+----------------------------------------------
--
id: Identity |
sd(_cons) | .7701702 .0663079 .6505825
.91174
-----------------------------+----------------------------------------------
--
sd(Residual) | 1.228557 .0345879 1.162602
1.298253
----------------------------------------------------------------------------
--
LR test vs. linear regression: chibar2(01) = 89.51 Prob >= chibar2 =
0.0000
. margins i.patgrp##i.time, atmeans post
Adjusted predictions Number of obs =
790
Expression : Linear prediction, fixed portion, predict()
at : 0.patgrp = .5037975 (mean)
1.patgrp = .4962025 (mean)
1.time = .2012658 (mean)
2.time = .2012658 (mean)
3.time = .2012658 (mean)
4.time = .1987342 (mean)
5.time = .1974684 (mean)
duration = 4.50981 (mean)
blmeds = 1.258228 (mean)
medchange = 1.235443 (mean)
hba1_bl = 8.798228 (mean)
----------------------------------------------------------------------------
--
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
patgrp |
0 | 8.165327 .1059938 77.04 0.000 7.957583
8.373071
1 | 7.807682 .1067051 73.17 0.000 7.598543
8.01682
|
time |
1 | 8.798743 .1149933 76.52 0.000 8.57336
9.024125
2 | 7.969287 .1149933 69.30 0.000 7.743905
8.19467
3 | 7.906579 .1149933 68.76 0.000 7.681196
8.131961
4 | 7.709288 .1156044 66.69 0.000 7.482708
7.935869
5 | 7.543528 .1159077 65.08 0.000 7.316353
7.770703
|
patgrp#time |
0 1 | 8.778096 .1621954 54.12 0.000 8.460198
9.095993
0 2 | 8.028096 .1621954 49.50 0.000 7.710198
8.345993
0 3 | 8.105596 .1621954 49.97 0.000 7.787699
8.423493
0 4 | 8.049346 .1621954 49.63 0.000 7.731448
8.367243
0 5 | 7.85825 .1638905 47.95 0.000 7.537031
8.179469
1 1 | 8.819705 .1632058 54.04 0.000 8.499828
9.139583
1 2 | 7.909579 .1632058 48.46 0.000 7.589701
8.229456
1 3 | 7.704515 .1632058 47.21 0.000 7.384638
8.024393
1 4 | 7.364025 .164965 44.64 0.000 7.0407
7.687351
1 5 | 7.223989 .1640654 44.03 0.000 6.902427
7.545551
----------------------------------------------------------------------------
--
I need to calculate the change in the adjusted means found under heading
patgrp#time in the margins output from time 5 to time 1 and then test to see
if this change is significant between the two groups. I tried using the
over option for margins but get an error that says margins cannot work with
its own posted results. I used pwcompare, but this appears to be the wrong
approach due to the issue of multiple comparisons, and also pwcompare would
not give me a p-value unless I used the bonferroni adjustment. I thought
about using lincom, but decided that was incorrect because I don't want to
subtract coefficients, I want to subtract adjusted means. I also tried to
use predict, but all I could get was yhat. The values of yhat are not the
same as margins. My advisors told me to use yhat at time 5 and subtract time
1 and then do a ttest. That sounded simple until I ran into the problem of
trying to subtract two values within the same variable. There must be a
simple way to get this result and I am just too novice to see it.
Beth Prezio
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/