Homework 5 code final.docx - Question 2 R Code and Output >...

This preview shows page 1 - 2 out of 2 pages.

Question 2 R Code and Output:> x<-c(1,1,1,1,1,1,0,0,1,0,1,0,1,0,0,1)> y<-c(1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0)> z<-gl(8,2)> mantelhaen.test(x,y,z,correct=F)Mantel-Haenszel chi-squared test without continuity correctiondata: x and y and zMantel-Haenszel X-squared = 1, df = 1, p-value = 0.3173alternative hypothesis: true common odds ratio is not equal to 195 percent confidence interval:0.3120602 28.8405896sample estimates:common odds ratio 3 Question 4 R Code and Output:> m2 <- glm(y ~ x1 + x3, family=binomial, data=bindat)> m <- glm(y ~ x1 + x2 + x3 + x4, family=binomial, data=bindat)> anova(m2,m)Analysis of Deviance TableModel 1: y ~ x1 + x3Model 2: y ~ x1 + x2 + x3 + x4Resid. Df Resid. Dev Df Deviance1 186 169.40 2 184 166.61 2 2.7894> 1-pchisq(2.7894,2)[1] 0.2479074> qchisq(0.95,2)[1] 5.991465> confint.default(m)2.5 %

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture