pdf("ex0110.pdf") # Read in data from ASCII formatted (Fixed With File) ex0110dat <- read.fwf("http://www.stat.ufl.edu/~winner/data/biostat/ex0110.dat", width=c(8,8), col.names=c("diagtest","goldstandard")) # Attach the dataset for analysis attach(ex0110dat) # Obtain crosstabulation of diagnostic test and gold standard freqdtgs <- table(diagtest, goldstandard) freqdtgs # Obtain the sensitivity and specificity and their complements # sensitivty=P(T+|D+)=cell(1,1)/column(1) # specificity=P(T-|D-)=cell(0,0)/column(0) sensspec <- prop.table(freqdtgs,2) sensspec # Obtain the Positive and Negative Predictive Values and their complements # PPV = P(D+|T+) = cell(1,1)/row(1) # NPV = P(D-|T-) = cell(0,0)/row(0) predval <- prop.table(freqdtgs,1) predval # Obtain the overall proportions in each cell, Accuracy=cell(0,0)+cell(1,1) propdtgs <- freqdtgs/sum(freqdtgs) propdtgs dev.off()