This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
hit.rate=c(0.0020 , 0.0355 , 0.1120 , 0.5730)
fa.rate=c(0.9885,0.9375,0.6815,0.466)
dprime.est=qnorm(hit.rate)-qnorm(fa.rate)
c.est=-qnorm(fa.rate)
dprime.est
## [1] -5.1515964 -3.3395980 -1.6878579 0.2693459
c.est
## [1] -2.27343465 -1.53412054 -0.47189743 0.08532879
y20=c(4,1996,1977,23,71,1929,1875,125,224,1779,1363,637,1146,854,932,1068)
#log likelihood for signal detection
#par=c(d’,c)
#y=c(hit,miss,fa,cr)
ll.sd=function(par,y20)
{
p=1:4
p[1]=1-pnorm(par[2],par[1],1)
p[2]=1-p[1]
p[3]=1-pnorm(par[2],0,1)
p[4]=1-p[3]
sum(y20*log(p))
}
par=c(1,0) #starting values
optim(par,ll.sd,y20=y20)
## $par
## [1] 0.1890015 -8.1017090
##
## $value
## [1] -307708.8
##
## $counts
## function gradient
## 429 NA
##
## $convergence
## [1] 0
##
## $message
## NULL
hit.rate=c(0.0020 ,0.0375 , 0.1495 , 0.7225)
fa.rate=c(0.9885 , 0.9260 , 0.6075 , 0.0735)
dprime.est=qnorm(hit.rate)-qnorm(fa.rate)
c.est=-qnorm(fa.rate)
dprime.est
## [1] -5.151596 -3.227096 -1.311389 2.040494
c.est
## [1] -2.2734347 -1.4466321 -0.2728091 1.4502099
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.