Re: [R] lme to determine if there is a group effect

2016-08-25 Thread Thierry Onkelinx
Dear John,

lme() not longer requires a GroupedData object. You can directly use a
data.frame which is easier to specify different models.

You want something like

lme(value ~ time * group, random = ~ time|SS, data = data1)

PS Note that the R-Sig-mixedmodels is more suited for this kind of question.

Best regards,

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

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

2016-08-25 0:46 GMT+02:00 John Sorkin :

> I apologize for sending this message again. The last time I sent it, the
> subject line was not correct. I have corrected the subject line.
>
> 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
>
> > # This is my data
> > data1
>SS group time value baseline
> 1   1  Cont0  9.00 9.00
> 2   2  Cont0  3.00 3.00
> 3   3  Cont0  8.00 8.00
> 4   4  Inte0  5.690702 5.690702
> 5   5  Inte0  7.409493 7.409493
> 6   6  Inte0  7.428018 7.428018
> 7   1  Cont3 13.713148 9.00
> 8   2  Cont3  9.841107 3.00
> 9   3  Cont3 12.843236 8.00
> 10  4  Inte3  9.300899 5.690702
> 11  5  Inte3 10.936389 7.409493
> 12  6  Inte3 12.358499 7.428018
> 13  1  Cont6 18.952390 9.00
> 14  2  Cont6 15.091527 3.00
> 15  3  Cont6 17.578812 8.00
> 16  4  Inte6 12.325499 5.690702
> 17  5  Inte6 15.486513 7.409493
> 18  6  Inte6 18.284965 7.428018
> > # 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  BIClogLik
>   74.59447 81.54777 -28.29724
>
> Random effects:
>  Formula: ~time | SS
>  Structure: General positive-definite
> StdDevCorr
> (Intercept) 1.3875111 (Intr)
> time0.2208046 -0.243
>
>  Formula: ~time | group %in% SS
>  Structure: General positive-definite
> StdDevCorr
> (Intercept) 1.3875115 (Intr)
> time0.2208051 -0.243
> Residual0.3800788
>
> Fixed effects: value ~ time
>Value Std.Error DF   t-value p-value
> (Intercept) 6.747442 0.8135067 11  8.294268   0
> time1.588653 0.1326242 11 11.978601   0
>  Correlation:
>  (Intr)
> time -0.268
>
> Standardized Within-Group Residuals:
> Min  Q1 Med  Q3 Max
> -1.11412947 -0.44986535  0.08034174  0.34615610  1.29943887
>
> 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 ...{{dropped:16}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] lme to determine if there is a group effect

2016-08-24 Thread Bert Gunter
I never used the groupedData structure, precisely because I found it
confusing, but I think:

1. group is *not* a (random) grouping variable; it's a fixed effect covariate.
2. so I believe your groupedData call should be:

GD<- groupedData(value~time|SS,data=data1,outer = group)

Of course, as you did not give us your data in a convenient form, I
can't check. Please let us know if this is wrong, however, as I don't
want to mislead others down the primrose path.


Cheers,
Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 24, 2016 at 3:46 PM, John Sorkin
 wrote:
> I apologize for sending this message again. The last time I sent it, the 
> subject line was not correct. I have corrected the subject line.
>
> 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
>
>> # This is my data
>> data1
>SS group time value baseline
> 1   1  Cont0  9.00 9.00
> 2   2  Cont0  3.00 3.00
> 3   3  Cont0  8.00 8.00
> 4   4  Inte0  5.690702 5.690702
> 5   5  Inte0  7.409493 7.409493
> 6   6  Inte0  7.428018 7.428018
> 7   1  Cont3 13.713148 9.00
> 8   2  Cont3  9.841107 3.00
> 9   3  Cont3 12.843236 8.00
> 10  4  Inte3  9.300899 5.690702
> 11  5  Inte3 10.936389 7.409493
> 12  6  Inte3 12.358499 7.428018
> 13  1  Cont6 18.952390 9.00
> 14  2  Cont6 15.091527 3.00
> 15  3  Cont6 17.578812 8.00
> 16  4  Inte6 12.325499 5.690702
> 17  5  Inte6 15.486513 7.409493
> 18  6  Inte6 18.284965 7.428018
>> # 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  BIClogLik
>   74.59447 81.54777 -28.29724
>
> Random effects:
>  Formula: ~time | SS
>  Structure: General positive-definite
> StdDevCorr
> (Intercept) 1.3875111 (Intr)
> time0.2208046 -0.243
>
>  Formula: ~time | group %in% SS
>  Structure: General positive-definite
> StdDevCorr
> (Intercept) 1.3875115 (Intr)
> time0.2208051 -0.243
> Residual0.3800788
>
> Fixed effects: value ~ time
>Value Std.Error DF   t-value p-value
> (Intercept) 6.747442 0.8135067 11  8.294268   0
> time1.588653 0.1326242 11 11.978601   0
>  Correlation:
>  (Intr)
> time -0.268
>
> Standardized Within-Group Residuals:
> Min  Q1 Med  Q3 Max
> -1.11412947 -0.44986535  0.08034174  0.34615610  1.29943887
>
> 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 ...{{dropped:12}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] lme to determine if there is a group effect

2016-08-24 Thread John Sorkin
I apologize for sending this message again. The last time I sent it, the 
subject line was not correct. I have corrected the subject line.
 
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
 
> # This is my data
> data1
   SS group time value baseline
1   1  Cont0  9.00 9.00
2   2  Cont0  3.00 3.00
3   3  Cont0  8.00 8.00
4   4  Inte0  5.690702 5.690702
5   5  Inte0  7.409493 7.409493
6   6  Inte0  7.428018 7.428018
7   1  Cont3 13.713148 9.00
8   2  Cont3  9.841107 3.00
9   3  Cont3 12.843236 8.00
10  4  Inte3  9.300899 5.690702
11  5  Inte3 10.936389 7.409493
12  6  Inte3 12.358499 7.428018
13  1  Cont6 18.952390 9.00
14  2  Cont6 15.091527 3.00
15  3  Cont6 17.578812 8.00
16  4  Inte6 12.325499 5.690702
17  5  Inte6 15.486513 7.409493
18  6  Inte6 18.284965 7.428018
> # 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  BIClogLik
  74.59447 81.54777 -28.29724

Random effects:
 Formula: ~time | SS
 Structure: General positive-definite
StdDevCorr  
(Intercept) 1.3875111 (Intr)
time0.2208046 -0.243

 Formula: ~time | group %in% SS
 Structure: General positive-definite
StdDevCorr  
(Intercept) 1.3875115 (Intr)
time0.2208051 -0.243
Residual0.3800788   

Fixed effects: value ~ time 
   Value Std.Error DF   t-value p-value
(Intercept) 6.747442 0.8135067 11  8.294268   0
time1.588653 0.1326242 11 11.978601   0
 Correlation: 
 (Intr)
time -0.268

Standardized Within-Group Residuals:
Min  Q1 Med  Q3 Max 
-1.11412947 -0.44986535  0.08034174  0.34615610  1.29943887 

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. 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.