-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.R
79 lines (61 loc) · 2.58 KB
/
script.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# install.packages("plyr")
# install.packages("esc")
# install.packages("EValue")
library(plyr)
library(esc)
library(EValue)
setwd("./data/proc")
# write output to file: comment out if printing to console
sink('evalues.txt', append=FALSE, split=FALSE)
# ----- BIOS1168 -----
df <- read.csv('bios1168_clean_.csv', header=TRUE, sep=',', na.strings=c('', '.', 'NA'))
# get summary stats
cdf <- ddply(df, c("group"), summarise,
N = length(ese_100_percent),
mean = mean(ese_100_percent, na.rm=TRUE),
sd = sd(ese_100_percent, na.rm=TRUE),
se = sd / sqrt(N))
# linear model
md <- lm(ese_100_percent ~ group, data=df)
# get Cohen's d standardised mean difference and SE for E value
# esc calculates difference as grp1m - grp2m
smd <- esc_mean_se(grp2m = cdf$mean[c(1)], grp2se = cdf$se[c(1)], grp2n = cdf$N[c(1)],
grp1m = cdf$mean[c(2)], grp1se = cdf$se[c(2)], grp1n = cdf$N[c(2)],
es.type = "d")
# compute evalue
eval <- evalues.MD(est=smd$es, se=smd$se)
cat("\n================================================================\n")
cat("BIOS1168 End-semester mark: Cohen's d")
cat("\n================================================================\n")
print(smd)
cat("\n================================================================\n")
cat("E value")
cat("\n================================================================\n")
print(eval)
# ----- BIOS5090 -----
df <- read.csv('bios5090_clean_.csv', header=TRUE, sep=',', na.strings=c('', '.', 'NA'))
# get summary stats
cdf <- ddply(df, c("group"), summarise,
N = length(ese_100_percent),
mean = mean(ese_100_percent, na.rm=TRUE),
sd = sd(ese_100_percent, na.rm=TRUE),
se = sd / sqrt(N))
# linear model
md <- lm(ese_100_percent ~ group, data=df)
# get Cohen's d standardised mean difference and SE for E value
# esc calculates difference as grp1m - grp2m
smd <- esc_mean_se(grp2m = cdf$mean[c(1)], grp2se = cdf$se[c(1)], grp2n = cdf$N[c(1)],
grp1m = cdf$mean[c(2)], grp1se = cdf$se[c(2)], grp1n = cdf$N[c(2)],
es.type = "d")
# compute evalue
eval <- evalues.MD(est=smd$es, se=smd$se)
cat("\n================================================================\n")
cat("BIOS5090 End-semester mark: Cohen's d")
cat("\n================================================================\n")
print(smd)
cat("\n================================================================\n")
cat("E value")
cat("\n================================================================\n")
print(eval)
# close file
sink()