Re: [R] (robust) mixed-effects model with covariate

2006-07-26 Thread Giuseppe Pagnoni
Dear Thilo,

many thanks for your reply.  I realized that there was an error in my 
formula which should have been:

aov(y ~ Group * (Time + Age) + Error (Subj/Time), data=df1)

or alternatively:

lme(RVP.A ~ Group*(Time+Age), random = ~ 1|Subj/Time,data=df1)

but I get different results in each case, and different still from the 
results of another stat program (JMP).
The problem is that I am not sure which one (if one indeed is) correct!

Also, in the model you proposed:

lme(y~Group*Time, random ~ age | Subj, data = df1)

it appears that age is not between the effects of interests, so I do not 
get an estimate of the significance of the Age or the Age*Group effect.

I have Pinheiro  Bates, and I read the first chapter but it didn't seem 
to provide an example analogous to my case.  Also, it looks like it 
would take me some months to study the book thoroughly and frankly that 
seems a bit excessive for such a (apparently?) simple problem  I was 
hoping somebody would magically provide the correct syntax :-)  !

thanks again anyway for your help

best regards

   giuseppe



Thilo Kellermann wrote:
 On Monday 24 July 2006 20:16, Giuseppe Pagnoni wrote:
   
 Dear all,

 First of all I apologize if you received this twice: I was checking the
 archive and I noticed that the text was scrubbed from the message,
 probably due to some setting in my e-mail program.


 I am unsure about how to specify a model in R and I thought of asking
 some advice to the list. I have two groups (Group= A, B) of subjects,
 with each subject undertaking a test before and after a certain
 treatment (Time= pre, post). Additionally, I want to enter
 the age of the subject as a covariate (the performance on the test is
 affected by age), and I also want to allow different slopes for the
 effect of age in the two groups of subjects (age might affect the
 performance of the two groups differentially).

 Is the right model to use something like the following?

 aov (y ~ Group*Time + Group*Age + Error(Subj/Group), data=df1 )

 (If I enter that command, within summary, I get the following:
 Error() model is singular in: aov(y ~ Group * Time + Group * Age +
 Error(Subj/Group), data = df1))

 
 try:
 aov(y~Group*Time*Age + Error(Subj*Time*Age), data = df1)
 which specifies an ANOVA (but not with mixed effects) with three main effects 
 and all interaction terms plus an error term that is independent between 
 groups (!) and relates to within subjects variability.

 For a real mixed effects analysis you should use the (n)lme function from 
 the nlme package and one possible model could look like this:

 lme(y~Group*Time, random ~ age | Subj, data = df1)

 but the exact specification depends on your assumptions, in which it is 
 possible to specify two or three models and compare their fits with anova(). 
 For more information on mixed effects you should consult:
 Jose C. Pinheiro  Douglas M. Bates (2000) Mixed-Effects Models in S and 
 S-PLUS. Springer, New York.

 Good luck,
 Thilo

   
 As a second question: I have an outlier in one of the two groups. The
 outlier is not due to a measurement error but simply to the performance
 of the subject (possibly related to his medical history, but I have no
 way to determine that with certainty). This subject is
 signaled to be an outlier within its group: averaging the pre and post
 values for the performance of the subjects in his group, the Grubbs test
 yields a probability of 0.002 for the subject to be an outlier (the
 subject is marked as a significant outlier also if I
 perform the test separately on the pre and the post data).

 If I remove this subject from its group, I get significant effects of
 Group and Group X Age (not using the R formula above, but another stat
 software), but if I leave the subject in those effects disappear. Since
 I understand that removing outliers is always worrysome, I would like to
 know if it is possible in R to estimate a model similar to that outlined
 above but in a resistant/robust fashion, and what would be the actual
 syntax to do that. I will very much appreciate any help or suggestion
 about this.

 thanks in advance and best regards

 giuseppe
 

   


-- 
-
Giuseppe Pagnoni
Psychiatry and Behavioral Sciences
Emory University School of Medicine
1639 Pierce Drive, Suite 4000
Atlanta, GA, 30322
tel: 404.712.8431
fax: 404.727.3233

__
R-help@stat.math.ethz.ch 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.


[R] (robust) mixed-effects model with covariate

2006-07-24 Thread Giuseppe Pagnoni
Dear all,

First of all I apologize if you received this twice: I was checking the 
archive and I noticed that the text was scrubbed from the message, 
probably due to some setting in my e-mail program.


I am unsure about how to specify a model in R and I thought of asking 
some advice to the list. I have two groups (Group= A, B) of subjects, 
with each subject undertaking a test before and after a certain 
treatment (Time= pre, post). Additionally, I want to enter
the age of the subject as a covariate (the performance on the test is 
affected by age), and I also want to allow different slopes for the 
effect of age in the two groups of subjects (age might affect the 
performance of the two groups differentially).

Is the right model to use something like the following?

aov (y ~ Group*Time + Group*Age + Error(Subj/Group), data=df1 )

(If I enter that command, within summary, I get the following:
Error() model is singular in: aov(y ~ Group * Time + Group * Age +
Error(Subj/Group), data = df1))


As a second question: I have an outlier in one of the two groups. The 
outlier is not due to a measurement error but simply to the performance 
of the subject (possibly related to his medical history, but I have no 
way to determine that with certainty). This subject is
signaled to be an outlier within its group: averaging the pre and post 
values for the performance of the subjects in his group, the Grubbs test 
yields a probability of 0.002 for the subject to be an outlier (the 
subject is marked as a significant outlier also if I
perform the test separately on the pre and the post data).

If I remove this subject from its group, I get significant effects of 
Group and Group X Age (not using the R formula above, but another stat 
software), but if I leave the subject in those effects disappear. Since 
I understand that removing outliers is always worrysome, I would like to 
know if it is possible in R to estimate a model similar to that outlined 
above but in a resistant/robust fashion, and what would be the actual 
syntax to do that. I will very much appreciate any help or suggestion 
about this.

thanks in advance and best regards

giuseppe

-- 
-
Giuseppe Pagnoni
Psychiatry and Behavioral Sciences
Emory University School of Medicine
101 Woodruff Circle, Suite 4000
Atlanta, GA, 30322
tel: 404.712.8431
fax: 404.727.3233

__
R-help@stat.math.ethz.ch 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.


[R] (robust) mixed-effects model with covariate

2006-07-20 Thread Giuseppe Pagnoni
Dear all,

I am unsure about how to specify a model in R and I thought of asking  
some advice to the list.  I have two groups (Group= A, B) of  
subjects, with each subject undertaking a test before and after a  
certain treatment (Time= pre, post).  Additionally, I want to enter  
the age of the subject as a covariate (the performance on the test is  
affected by age), and I also want to allow different slopes for the  
effect of age in the two groups of subjects (age might affect the  
performance of the two groups differentially).

Is the right model to use something like the following?

aov (y ~ Group*Time + Group*Age + Error(Subj/Group), data=df1 )

(If I enter that command, within summary, I get the following:
Error() model is singular in: aov(y ~ Group * Time + Group * Age +  
Error(Subj/Group), data = df1))


As a second question: I have an outlier in one of the two groups.   
The outlier is not due to a measurement error but simply to the  
performance of the subject (possibly related to his medical history,  
but I have no way to determine that with certainty).  This subject is  
signaled to be an outlier within its group: averaging the pre and  
post values for the performance of the subjects in his group, the  
Grubbs test yields a probability of 0.002 for the subject to be an  
outlier (the subject is marked as a significant outlier also if I  
perform the test separately on the pre and the post data).

If I remove this subject from its group, I get significant effects of  
Group and Group X Age (not using the R formula above, but another  
stat software), but if I leave the subject in those effects  
disappear.  Since I understand that removing outliers is always  
worrysome, I would like to know if it is possible in R to estimate a  
model similar to that outlined above but in a resistant/robust  
fashion, and what would be the actual syntax to do that.  I will very  
much appreciate any help or suggestion about this.

thanks in advance and best regards

giuseppe



Giuseppe Pagnoni
Dept. of Psychiatry
101 Woodruff Circle
Altanta, GA 30322
Tel: 404-712-9582
Fax: 404-727-3233




[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.


[R] clustering a sparse dissimilarity matrix

2006-03-30 Thread Giuseppe Pagnoni
Dear all,

I have a BIG dissimilarity matrix (around one thousand by one thousand), 
that I would like to cluster.  Most of the elements of the matrix are 
zero or close to zero.  Is there a way to cluster the matrix 
(hierarchical or partitioning methods) that discards those elements that 
are close to zero (by using a specified threshold on the matrix)? I am 
asking this because otherwise I get a huge amount of clutter for 
singletons or very small clusters.  Also, how can you look for clusters 
of a specified  size, apart from looking visually at the dendrogram?  Is 
there a way to bias the algorithm specifically for clusters of a certain 
size?

thank you very much for any suggestion

best regards

   giuseppe

PS
Note that I cannot use the original data instead of the dissimilarity 
matrix because those are dissimilarities (computed from the spatial 
correlation coefficient) between fMRI brain maps, each of which has 
around 6 variables.

-- 
-
Giuseppe Pagnoni
Psychiatry and Behavioral Sciences
Emory University School of Medicine
1639 Pierce Drive, Suite 4000
Atlanta, GA, 30322
tel: 404.712.8431
fax: 404.727.3233

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] power in a specific frequency band

2004-10-15 Thread Giuseppe Pagnoni
Dear R users
I have a really simple question (hoping for a really simple answer :-):
Having estimated the spectral density of a time series x (heart rate 
data) with:

x.pgram - spectrum(x,method=pgram)
 I would like to compute the power in a specific energy band.
Assuming that frequency(x)=4 (Hz), and that I am interested in the band 
between f1 and f2, is the power in the band simply the following?

sum(x.pgram$spec[(x.pgram$freq  f1/frequency(x))  (x.pgram$freq = 
f2/frequency(x))])

If it is so, are the returned units the same units as the original time 
series, but squared (if x is bpm, then the power is in bpm^2)?

I own a copy of Venables and Ripley (MASS 2003), but I was not able to 
extract this information from the time series chapter

thanks for any help
(please cc to my e-mail, if possible)
giuseppe


Giuseppe Pagnoni
Dept. Psychiatry and Behavioral Sciences
Emory University
1639 Pierce Drive, Suite 4000
Atlanta, GA, 30322
tel: 404.712.8431
fax: 404.727.3233
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] (REPOST) Simple main effects in 2-way repeated measure ANOVA

2004-08-09 Thread Giuseppe Pagnoni
Dear Prof. Ripley
I am sorry that reposting the mail was perceived as not complying to the 
correct list etiquette: I do not usually frequent the list and I just 
thought that the message went unnoticed.  I apologize for the insistence.

On the subject matter of the e-mail, yes, there was a typo, the error 
term was indeed Error(Subj/Time).  But I am still interested in 
examining the simple main effects, when the interaction of Time and 
Group is significant:

Time:
--
ControlGroup: before vs after
TreatmentGroup: before vs after
Group:
--
Before:  ControlGroup vs TreatmentGroup
After: ControlGroup vs TreatmentGroup
Is this incorrect statistical praxis?  Other software packages display 
the results for the above tests after the ANOVA.  However, I couldn't 
find a simple way to extract this information in R.

Also, I am not sure how to include a confounding variable, like Age, in 
the formulation of the model.

Thanks for your help
   giuseppe


Prof Brian Ripley wrote:
Why has this been REPOSTed?  It was delivered last Thursday.
On Sun, 8 Aug 2004, Giuseppe Pagnoni wrote:
 

I am running a 2-way repeated measure anova with 1 between-subjects 
factor (Group=treatment, control), and 1 within-subject factor (Time of 
measurement: time1, time2).  I extract the results of the anova with:

summary(aov(effect ~ Group*Time + Error=Subj/Time, data=mydata))
   

That's not valid syntax for an R formula. Did you mean Error(Subj/Time)?
 

Now, this must be clearly a dumb question, but how can I quickly 
extract in R all the post-hoc t-tests for the simple main effects?
   

I very much hope you cannot, as you have specified an interaction, and
you should not want t-tests for main effects in the presence of an 
interaction, and certainly not with the default R coding.

Did you mean Group + Time?
 

Also, while I am at it, how do I enter in the model a counfounding 
covariate (e.g., Age)?

And on a different matter, is there a way to receive interactive user 
input in an R script? Something like Enter the name of  the factor:  
, or even more simply Press Enter to see the result of the next 
analysis
   

?readline, or cat + scan or ... using connections.
 


--

Giuseppe Pagnoni, Ph.D.
Dept. of Psychiatry and Behavioral Sciences
1639 Pierce Drive, Suite 4000
WMB Bldg., Atlanta, GA 30322, U.S.
phone: 404-712-8431
fax: 404-727-3233
e-mail: [EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] (REPOST) Simple main effects in 2-way repeated measure ANOVA

2004-08-08 Thread Giuseppe Pagnoni
Hi all
I am running a 2-way repeated measure anova with 1 between-subjects 
factor (Group=treatment, control), and 1 within-subject factor (Time of 
measurement: time1, time2).  I extract the results of the anova with:

summary(aov(effect ~ Group*Time + Error=Subj/Time, data=mydata))
Now, this must be clearly a dumb question, but how can I quickly 
extract in R all the post-hoc t-tests for the simple main effects?

Also, while I am at it, how do I enter in the model a counfounding 
covariate (e.g., Age)?

And on a different matter, is there a way to receive interactive user 
input in an R script? Something like Enter the name of  the factor:  
, or even more simply Press Enter to see the result of the next 
analysis

thanks in advance for any suggestions!
   giuseppe

Giuseppe Pagnoni
Dept. Psychiatry and Behavioral Sciences
Emory University
1639 Pierce Drive, Suite 4000
Atlanta, GA, 30322
tel: 404.712.8431
fax: 404.727.3233
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Post-hoc t-tests in 2-way repeated measure ANOVA

2004-08-05 Thread Giuseppe Pagnoni
Hi all
I am running a 2-way repeated measure anova with 1 between-subjects 
factor (Group=treatment, control), and 1 within-subject factor (Time of 
measurement: time1, time2).  I extract the results of the anova with:

summary(aov(effect ~ Group*Time + Error=Subj/Time, data=mydata))
Now, this must be clearly a dumb question, but how can I quickly extract 
in R all the post-hoc t-tests for the simple main effects?

Also, while I am at it, how do I enter in the model a counfounding 
covariate (e.g., Age)?

And on a different matter, is there a way to receive interactive user 
input in an R script? Something like Enter the name of  the factor:  , 
or even more simply Press Enter to see the result of the next 
analysis

thanks in advance for any suggestions!
   giuseppe
--

Giuseppe Pagnoni, Ph.D.
Dept. of Psychiatry and Behavioral Sciences
1639 Pierce Drive, Suite 4000
WMB Bldg., Atlanta, GA 30322, U.S.
phone: 404-712-8431
fax: 404-727-3233
e-mail: [EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html