m13=binom.test(4,13,p=0.27,alternative='greater')
m14=binom.test(2,12,p=0.19,alternative='greater')
m11=binom.test(3,12,p=0.33,alternative='greater')
cbind(lapply(list(m13,m14,m11),function(x) return(x$p.value) ))
[,1]
[1,] 0.4825762
[2,] 0.6957058
[3,] 0.8124391
m17=binom.test(6,15,p=0.35,alternative='greater')
m15=binom.test(0,17,p=0.14,alternative='greater')
m18=binom.test(5,14,p=0.36,alternative='greater')
m19=binom.test(4,15,p=0.2,alternative='greater')
m16=binom.test(4,16,p=0.06,alternative='greater')
cbind(lapply(list(m17,m15,m18,m19,m16),function(x) return(x$p.value) ))
[,1]
[1,] 0.4357179
[2,] 1
[3,] 0.6079885
[4,] 0.3518379
[5,] 0.01316628
#for comparison, CP(LM:L) response rates are *** significantly higher than FPR
#e.g. ZF15
binom.test(14,18,p=0.14,alternative='greater')
Exact binomial test
data: 14 and 18
number of successes = 14, number of trials = 18,
p-value = 1.943e-09
alternative hypothesis: true probability of success is greater than 0.14
95 percent confidence interval:
0.5611172 1.0000000
sample estimates:
probability of success
0.7777778
sessions_to_LC=c(8,7,7,
7,15,7,9,15,
9,6,7,8.5,4)
grp=c("LM_A","LM_A","LM_A",
"LM_B","LM_B","LM_B","LM_B","LM_B",
"L_0","L_0","L_0","L_0","L_0")
dfr=data.frame(LC=sessions_to_LC,group=grp)
glmP.out=glm(LC~group,data=dfr,family='poisson')
Warning: non-integer x = 8.500000
summary(glmP.out)
Call:
glm(formula = LC ~ group, family = "poisson", data = dfr)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.1992 -0.5047 -0.1240 0.5876 1.2712
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.93152 0.17025 11.345 <2e-16 ***
groupLM_A 0.06091 0.27284 0.223 0.8233
groupLM_B 0.42933 0.21875 1.963 0.0497 *
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 13.357 on 12 degrees of freedom
Residual deviance: 8.848 on 10 degrees of freedom
AIC: Inf
Number of Fisher Scoring iterations: 4
#Percentage change in LC for LM_B vs L_0
(exp(glmP.out$coefficients['groupLM_B'])-1)*100
groupLM_B
53.62319
IDs=c('z15','z16','z17','z18','z19')
CSgo=c(151,156,147,114,114)
CSnogo=c(41,34,15,31,28)
Lgo=c(14,20,28,21,24)
Lnogo=c(4,1,0,2,2)
dfr=data.frame(cond='LM:LM',CP=CSgo,FN=CSnogo,id=IDs )
dfr=rbind(dfr,
data.frame(cond='LM:L',CP=Lgo,FN=Lnogo,id=c('z15','z16','z17','z18','z19') )
)
dfr$rate=dfr$CP/(dfr$FN+dfr$CP)
dfr$odds=dfr$rate/(1-dfr$rate)
dfr$logodd=log(dfr$odds)
#aggregate(cbind(rate,odds,logodd) ~ cond,data=dfr,FUN=mean)
library(lme4)
Loading required package: Matrix
mixB.out<-lme4::glmer(cbind(CP, FN) ~ cond + (1 | id) ,family = binomial, data = dfr)
summary(mixB.out)->s
print(s)
Generalized linear mixed model fit by maximum likelihood
(Laplace Approximation) [glmerMod]
Family: binomial ( logit )
Formula: cbind(CP, FN) ~ cond + (1 | id)
Data: dfr
AIC BIC logLik deviance df.resid
57.3 58.3 -25.7 51.3 7
Scaled residuals:
Min 1Q Median 3Q Max
-1.82586 -0.22402 -0.00092 0.41184 1.19998
Random effects:
Groups Name Variance Std.Dev.
id (Intercept) 0.09391 0.3064
Number of obs: 10, groups: id, 5
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 2.4871 0.3738 6.655 2.84e-11 ***
condLM:LM -0.9340 0.3594 -2.599 0.00935 **
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr)
condLM:LM -0.898
logit <- function(ratio) {
log(ratio/(1-ratio))}
expit <- function(li) {
1/(1+exp(-li))
} # yields ratio
# MEAN LM:L
rL=expit(s$coefficients[1,1])
# MEAN LM:LM
rLM=expit(s$coefficients[1,1]+s$coefficients[2,1])
OR=(rL/(1-rL))/(rLM/(1-rLM))
# directly: OR=1/exp(s$coefficients[2,1])
print(paste("CPR (LM:L) :",rL))
[1] "CPR (LM:L) : 0.923234905230892"
print(paste("CPR (LM:LM):",rLM))
[1] "CPR (LM:LM): 0.825366479312474"
print(paste("Odds Ratio:",OR))
[1] "Odds Ratio: 2.54465674818237"