Professional Documents
Culture Documents
Man-fang Liang
2023-03-31
General model
Fit a general model with separate parameters for each condition.
′ ′ ′ ′ ′
With separate parameters for each condition, the general model has ten parameters: 𝑑𝐴 , 𝑐𝐴 , 𝑑𝐵 , 𝑐𝐵 , 𝑑𝐶 , 𝑐𝐶 , 𝑑𝐷 , 𝑐𝐷 , 𝑑𝐸 , 𝑐𝐸 .
1
#negative log likelihood for Model 2:
#assign par6=d,cA,cB,cC,cD,cE
#assign y20=(h1,m1,f1,c1,h2,m2,f2,c2...)
nll.sd.2=function(par6,y20)
{
nll.sd(par6[1:2],y20[1:4])+
nll.sd(par6[c(1,3)],y20[5:8])+
nll.sd(par6[c(1,4)],y20[9:12])+
nll.sd(par6[c(1,5)],y20[13:16])+
nll.sd(par6[c(1,6)],y20[17:20])
}
MLE
Read data from table 3.4.
dat <- as.integer(unlist(strsplit("404 96 301 199 348 152 235 265 287 213 183 317 251 249 102 398 148 35
# General model
# par=rep(0.5, 10) #starting values
# mod1=optim(par,nll.1,y20=dat,hessian=T)
mod1_loglike <- 0.0
mod1_par <- c()
genSE <- c()
for (i in 1:5) {
mod <- optim(c(1, 0),
nll.sd,
y=dat_mat[i, ],hessian=T
)
# Common-sensitivity model
par=rep(0.5, 6) #starting values
mod2=optim(par,nll.sd.2,y20=dat,hessian=T)
2
# general model
# mod1_par <- mod1$par
names(mod1_par) <- c('dA\'', 'cA', 'dB\'', 'cB', 'dC\'', 'cC', 'dD\'', 'cD', 'dE\'', 'cE')
mod1_par
# Common-sensitivity model
mod2_par <- mod2$par
names(mod2_par) <- c('d\'', 'cA', 'cB', 'cC', 'cD', 'cE')
mod2_par
## d' cA cB cC cD cE
## 0.7096255 -0.2165652 0.1327715 0.4343349 0.7586419 1.3946258
xpos=barplot(plotdat,
names.arg=c('A', 'B', 'C', 'D', 'E'),
col='lightblue',ylim=c(0,1.5),space=.5,
xlab='Conditions',
ylab='Sensitivity parameters')
errbar(xpos,plotdat,genSE,.3)
3
1.2
Sensitivity parameters
0.8
0.4
0.0
A B C D E
Conditions
Plot the data as an ROC and add a line denoting the common-
sensitivity model.
Data points
4
Common-sensitivity model line
## [1] 0.7096255
plot
par(pty="s")
plot(qnorm(ROC_data_pf),qnorm(ROC_data_ph),ylab="z(Hit Rate)",
xlab="z(False-Alarm Rate)", pch=16 , asp = 1,ylim=c(-2,2),xlim=c(-2,2))
lines(g, ph)
legend('bottomright', legend=c("Data points", "Model prediction (d'=0.71)"), col=c("black", "black"), pc
5
2
1
z(Hit Rate)
0
−1
Data points
Model prediction (d'=0.71)
−2
−2 −1 0 1 2
z(False−Alarm Rate)
′ ′ ′ ′ ′
Null-hypothesis: 𝑑𝐴 = 𝑑𝐵 = 𝑑𝐶 = 𝑑𝐷 = 𝑑𝐸
# G-squared
G2 <- 2*(mod2$value-mod1_loglike)
G2
## [1] 30.92364
## [1] 9.487729
Under the null-hypothesis, 𝐺2 should be distributed as a chi-square. 𝐺2 is 30.92, larger than the critical
value of 9.49 with 4 degrees of freedom. The null hypothesis has been rejected. The sensitivity parameter
statistical significantly varies across conditions.