-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruncontrast_d.R
More file actions
19 lines (17 loc) · 882 Bytes
/
runcontrast_d.R
File metadata and controls
19 lines (17 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
## requires runcontrast.R, cohensd.R and returnAdj.R
# calculates Cohen's D effect Size (adjusted for covariates) for runcontrast output
# dat- main dataframe with all your subject info/data
# results- results from runcontrast
# name of group variable (eg. 'Group')
# NOTE: Group identifiers CANNOT contain '-' (eg. 'BP-P' must be 'BPP','BP_P',etc)
# NOTE: Group identifiers in 'contr' column of runcontrast output must match original data frame in Group column
# covars= list of covariates (c('age','sex','site'))
runcontrast_d<-function(dat, results,group,covars){
for(x in 1:length(results[,'contr'])){
tmp<-strsplit(as.character(results[,'contr'][x]),'-')
group1<-gsub(" ","", unlist(tmp)[1])
group2<-gsub(" ","", unlist(tmp)[2])
results[,'d'][x]<-(effect_size(dat,as.character(results[,'region'][x]), group,group1,group2,covars))
}
return(results)
}