McNemar (via Agresti) Time1-Time2 Dichotomous data
ratings <- matrix(c(794,150, 86, 570), ncol=2, byrow=TRUE,
+ dimnames = list("First Survey" = c("Approve", "Disapprove"),
+ "Second Survey" = c("Approve", "Disapprove")))
> mcnemar.test(ratings, correct=FALSE)
-----------------------------
R-session
> ?mcnemar.test
> ratings <- matrix(c(794,150, 86, 570), ncol=2, byrow=TRUE,
+ dimnames = list("First Survey" = c("Approve", "Disapprove"),
+ "Second Survey" = c("Approve", "Disapprove")))
> mcnemar.test(ratings, correct=FALSE)
McNemar's Chi-squared test
data: ratings
McNemar's chi-squared = 17.3559, df = 1, p-value = 3.099e-05
> ratings
Second Survey
First Survey Approve Disapprove
Approve 794 150
Disapprove 86 570
> sqrt(17.36)
[1] 4.166533
> #Agresti p.411; decline in approval from .59 to .55 (signif) CI (-.06,-.02)
# see R-package "PropCIs"
# manual at http://cran.r-project.org/web/packages/PropCIs/PropCIs.pdf
> install.packages("PropCIs")
Installing package(s) into ‘C:/Users/rag/Documents/R/win-library/2.14’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://cran.stat.ucla.edu/bin/windows/contrib/2.14/PropCIs_0.1-7.zip'
Content type 'application/zip' length 48541 bytes (47 Kb)
opened URL
downloaded 47 Kb
package ‘PropCIs’ successfully unpacked and MD5 sums checked
The downloaded packages are in
C:\Users\rag\AppData\Local\Temp\RtmpINgSzT\downloaded_packages
> library(PropCIs)
Warning message:
package ‘PropCIs’ was built under R version 2.14.2
> diffpropci.mp(150,86, 1600, .95)
data:
95 percent confidence interval:
-0.05868294 -0.02121719
sample estimates:
[1] -0.03995006
References
Agresti, A. and Min, Y. (2005) Simple improved confidence intervals
for comparing matched proportions. Statistics in Medicine 24 (5),
729–740.
diffpropci.mp Adjusted Wald interval for a difference of proportions with matched
pairs
Description
AdjustedWald interval for a difference of proportions with matched
pairs. This is the interval called Wald+2 in Agresti and Min (2005).
Adds 0.5 to each cell before constructing the Wald CI