Bootstrap sur effect size (ges)

Postez ici vos questions, réponses, commentaires ou suggestions - Les sujets seront ultérieurement répartis dans les archives par les modérateurs

Modérateur : Groupe des modérateurs

Sophie SCHLATTER
Messages : 1
Enregistré le : 09 Mai 2016, 06:36

Bootstrap sur effect size (ges)

Messagepar Sophie SCHLATTER » 22 Juil 2016, 04:20

Bonjour tout le monde,

Merci de ce site très utiles. Alors je suis en train d'effectuer une anova à mesures répétées. J'utilise pour cela le package (ez anova). Cependant j'ai des doutes sur son utilisation,notamment comment préciser à "R" que mes plans ne sont pas balancé. Ensuite j'essaye d'appliquer la méthode du bootstrap sur mes effect size (ges) que mon modèle me donne.
Es ce que quelqu’un pourrais jeter un coup d’œil a mon script et essayer de m'aider à identifier mon (surement mes) erreurs. Merci, Sophie

# My main question: Does the treatment affect "Att"?

# P are the name of the participants (factor)
# For each P, I have two treatment "A" and "C"
# So for each P, we have two mesures of Att ( one at "A" and one at "C")

str(finalA)
$ Day : Factor w/ 2 levels "1","2": 2 1 1 2 1 1 1 1 1 2 ...
$ P : Factor w/ 116 levels "3","14","47",..: 6 7 12 15 16 17 20 21 23 26 ...
$ Treatment : Factor w/ 3 levels "A","B","C": 1 1 1 1 1 1 1 1 1 1 ...
$ Order : Factor w/ 4 levels "1","2","3","4": 3 1 1 3 1 1 1 1 1 3 ...
$ Number.F : int 1 0 2 5 5 2 5 3 6 6 ...
$ Att : num 3.71 3.02 3.88 2.93 2.99 ...
$ sex.rater : Factor w/ 2 levels "f","m": 2 1 2 1 2 2 2 2 2 2 ...
$ ratio.W.H : num 0.449 0.301 0.389 0.312 0.31 ...
$ ethnicity : Factor w/ 2 levels "C","other": 2 1 1 2 2 1 1 1 1 2 ...
$ relat.stat.long.: Factor w/ 2 levels "no","yes": 1 2 2 2 1 2 1 2 1 1 ...
$ smoker : Factor w/ 2 levels "no","y": 1 1 1 1 1 2 1 1 1 1 ...
$ sex_exp : Factor w/ 2 levels "f","m": 1 1 1 1 1 1 1 1 1 1 ...



# My main question is to see if the Treatment affect "Att"
?ezANOVA

# Just to help the function to run
finalA$P<-factor(finalA$P)
finalA$P = droplevels(finalA$P)
finalA$Treatment = droplevels(finalA$Treatment)

mod0 <-ezANOVA(
data=finalA,
wid=P,
dv=Att,
within=.(Treatment),
type = 2 # It is a good way to "tell to R that my plan are unbalanced?"
between=NULL) # I would like to add more predictor variable at the same time (ei;sex, rater)

# My model give me an effect size wich is a ges (Generalized Eta-Squared measure of effect size (see in references: Bakeman, 2005).)
# Now I want an IC on this effect size
# I am triing to do the bootstrapp method

mod0$ANOVA$ges[1] # here [1] seems useless but after I will have more lignes

# So I want to generate a new data set in "Att" for each means Treatment A and Treatment C
x1 <- finalA$Att[finalA$Treatment == "A" ]
x2 <- finalA$Att[finalA$Treatment == "C" ]

# we chose arbiratory the nb of boot we chose 1000 repetition
# we want to réechantillonate in two vectors (x1 and x2)

gesCI<-function(x1,x2,nbboot=1000){
output<-numeric(nbboot)
for(i in 1:nbboot){
x1bis<-sample(x1,replace=T)
x2bis<-sample(x2,replace=T)
Attbis<-rbind(x1bis,x2bis) # TRICKY PART : I WANT THEM IN A NEW DATAFRAME
finalXAtt <- cbind(finalA,Attbis)
ezANOVA(
data=finalXAtt,
wid=P,
dv=Attbis,
within=.(Treatment),
between=sex.rater,
type = 2 )
output[i]<- output$ANOVA$ges[2] # on stok
}
return(c(output$ANOVA$ges[2]),quantile(output,c(0.025,0.975)))
}

gesCI(x1,x2)
# message alerte : "Attbis" is not a variable in the data frame provided.
# Q: Could you please Hepl me to find the mistakes

# Cheers, Sophie

Retourner vers « Questions en cours »

Qui est en ligne

Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 1 invité