# simulate a dataset
group<-rep(c('case','cont'),rep(100,2))
pre<-rbinom(200,1,0.7)
post<-rbinom(200,1,0.8)
mcnemar.test(pre,post)
# create a variable post - pre
matched<-data.frame(pre,post,group)
matched$change<-post-pre
# McNemar's test from logistic regression (0 has to be deleted)
summary(glm(factor(change)~1, data=matched[matched$change!=0,],family=binomial))
summary(glm(factor(change)~group, data=matched[matched$change!=0,],family=binomial))
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment