cohen.d(sat.act,"gender")
#robust version
round(d.robust(sat.act,"gender")$robust.d,2)
#formula input is nicer
cohen.d(sat.act ~ gender) #formula input version
#if we want to report the group means, we grab the data in descriptive
cd <- cohen.d(sat.act ~ gender)
cd.df <- data.frame(d = cd$cohen.d[,"effect"], male = cd$descriptive$mean[1,cd$order[-1]],
female = cd$descriptive$mean[2, cd$order[-1]])
#report cohen.d by another group
cd <- cohen.d.by(sat.act,"gender","education")
cohen.d(SATV + SATQ ~ gender, data=sat.act) #just choose two variables
summary(cd) #summarize the output
#now do it for subsets and then pool them
cd1 <- cohen.d(sat.act[1:300,],group= "gender")
cd2 <- cohen.d(sat.act[301:600,],group="gender")
cd.pooled <- cohenPooled(list(cd1,cd2))
#graph them using error.dots
error.dots(stats=cd.pooled)
#or show them as two sets together using plot
plot(cd1,sort=FALSE)
plot(cd2,sort=FALSE,add=TRUE,col="red",lwd=2)
#formula version combines these functions
cd <- cohen.d(sat.act ~ gender + education) #find d by gender for each level of education
summary(cd)
if(require(psychTools)) {
mf.pers <- cohen.d(M.pers + F.pers ~ gender,data=GERAS.scales)
mf.pers.cog <- cohen.d(M.pers + F.pers + M.cog + F.cog ~ gender,data=GERAS.scales)
mf.pers.cog.act <- cohen.d(M.pers + F.pers + M.cog + F.cog + M.act + F.act ~ gender,
data=GERAS.scales)
mf.pers.cog.act.MF <- cohen.d(M.pers + F.pers + M.cog + F.cog + M.act + F.act + M + F ~ gender,
data=GERAS.scales)
mf.pers.cog.act.MF.all <- cohen.d(M.pers + F.pers + M.cog + F.cog + M.act + F.act + M + F
+ MF.all~ gender,data=GERAS.scales)
MF.all =cohen.d(MF.all~gender,data=GERAS.scales)
#summarize
summary.df <- data.frame(Scale_name=cs(person, person.cognitive, person.cognitive.activity,
All_MF_scales,MF.all),
N_subscales =c(2,4,6,8,1) , N_items =c(20,34,50,50,50),D = round(c(mf.pers$M.dist,
mf.pers.cog$M.dist, mf.pers.cog.act$M.dist, mf.pers.cog.act.MF$M.dist,
MF.all$M.dist) ,2))
}
#now show several examples of confidence intervals
#one group (d vs 0)
#consider the t from the cushny data set
t2d( -4.0621,n1=10)
d.ci(-1.284549,n1=10) #the confidence interval of the effect of drug on sleep
#two groups
d.ci(.62,n=64) #equal group size
d.ci(.62,n1=35,n2=29) #unequal group size
#several examples of d and t from data
m2d(52.58,-70.65,49.9,47.5) #Terman and Miles 1936
#graphically show the various overlap statistics
curve(d2OVL2(x),0,3,xlab="d",ylab="",lty="dashed",
main="Four representations of effect size (d) ")
curve(d2OVL(x),0,3,xlab="d",add=TRUE,)
curve(d2CL(x),0,3,add=TRUE)
curve(d2U3(x), add=TRUE,lty="dotted")
text(1,.37,"OVL2")
text(2,.37,"OVL")
text(1,.88,"U3")
text(2, .88,"CL")
Run the code above in your browser using DataLab