[R] function that converts data into a form that can be included in a question to mailing list
John Sorkin
jsorkin at grecc.umaryland.edu
Thu Aug 25 00:33:33 CEST 2016
I am trying to run a repeated measures analysis of data in which each subject (identified by SS) has 3 observations at three different times (0, 3, and 6). There are two groups of subjects (identified by group). I want to know if the response differs in the two groups. I have tried to used lme. Lme tell me if there is a time effect, but does not tell me if there is a group effect. Once I get this to work I will want to know if there is a significant group*time effect. Can someone tell me how to get an estimate for group. Once I get that, I believe getting an estimate for group*time should be straight forward. The code I have tired to use follows.
Thank you,
John
> data1
SS group time value baseline
1 1 Cont 0 6.000000 6.000000
2 2 Cont 0 3.000000 3.000000
3 3 Cont 0 5.000000 5.000000
4 4 Inte 0 14.132312 14.132312
5 5 Inte 0 8.868808 8.868808
6 6 Inte 0 14.602672 14.602672
7 1 Cont 3 10.706805 6.000000
8 2 Cont 3 8.469477 3.000000
9 3 Cont 3 9.337411 5.000000
10 4 Inte 3 16.941940 14.132312
11 5 Inte 3 13.872662 8.868808
12 6 Inte 3 20.465614 14.602672
13 1 Cont 6 16.687028 6.000000
14 2 Cont 6 13.177752 3.000000
15 3 Cont 6 14.276398 5.000000
16 4 Inte 6 23.453808 14.132312
17 5 Inte 6 18.229053 8.868808
18 6 Inte 6 25.334664 14.602672
> # Create a grouped data object. SS identifies each subject
> # group indentifies group, intervention or control.
> GD<- groupedData(value~time|SS/group,data=data1,FUN=mean)
> # Fit the model.
> fit1 <- lme(GD)
> cat("The results give information about time, but does not say if the gruops are different\n")
The results give information about time, but does not say if the gruops are different
> summary(fit1)
Linear mixed-effects model fit by REML
Data: GD
AIC BIC logLik
81.38094 88.33424 -31.69047
Random effects:
Formula: ~time | SS
Structure: General positive-definite
StdDev Corr
(Intercept) 3.371776404 (Intr)
time 0.009246535 1
Formula: ~time | group %in% SS
Structure: General positive-definite
StdDev Corr
(Intercept) 3.34070367 (Intr)
time 0.00915754 1
Residual 0.61279061
Fixed effects: value ~ time
Value Std.Error DF t-value p-value
(Intercept) 8.512446 1.9511580 11 4.362766 0.0011
time 1.654303 0.0592047 11 27.942107 0.0000
Correlation:
(Intr)
time -0.001
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-1.9691671 -0.4876710 0.1559464 0.4637269 1.6069444
Number of Observations: 18
Number of Groups:
SS group %in% SS
6 6
John David Sorkin M.D., Ph.D.
Professor of Medicine
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)
Confidentiality Statement:
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
More information about the R-help
mailing list