> fit <- glm (yºx1+x2+x3+x4, data = data, family = 'binomial') > summary(fit) Call: glm(formula - y - x1 + x2 + x3 + x4,
Posted: Mon May 02, 2022 12:26 pm
> fit <- glm (yºx1+x2+x3+x4, data = data, family = 'binomial') > summary(fit) Call: glm(formula - y - x1 + x2 + x3 + x4, family = "binomial", data = data) Deviance Residuals: Min 1Q Median -1.1871 -0.9402 -0.8203 Max 30 1.2234 1.6584 Coefficients: Estimate Std. Error z value Pr>Izl) (Intercept) -3.079830 3.872559 -0.795 0.426 x1 -0.466934 0.791325 -0.590 0.555 0.002161 0.032593 0.066 0.947 x3 1.585615 2.538500 0.625 0.532 x4 0.093598 0.237437 0.394 0.693 x2 (Dispersion parameter for binomial family taken to be 1) Null deviance: 39.429 on 29 degrees of freedom Residual deviance: 38.452 on 25 degrees of freedom AIC: 48.452 Number of Fisher Scoring iterations: 4 > fit1 <- glm(yºx3, data = data, family = 'binomial') > summary (fit1) Call: glm(formula - y - x3, family = "binomial", data - data) Deviance Residuals:
Min 19 Median 30 Max -1.0918 -0.9597 -0.8617 1.2999 1.6406 Coefficients: Estimate Std. Error z value Pr(>21) (Intercept) -2.870 3.418 -0.840 0.401 x3 1.753 2.552 0.687 0.492 (Dispersion parameter for binomial family taken to be 1) Null deviance: 39.429 Residual deviance: 38.944 AIC: 42.94 on 29 degrees of freedom on 28 degrees of freedom Number of Fisher Scoring iterations: 4 > exp(coefficients (fit1)) [2] x3 5.773179 > lrtest(fiti) Likelihood ratio test Model 1: yx3 Model 2: y 1 #Df LogLik Df Chisq Pr(>Chisq) 1 2 -19.472 2 1 -19.715 -1 0.485 0.4861 > fit2 <- glm(y"x4, data = data, family = 'binomial') > summary(fit2) Call: glm(formula - y - x4, family = "binomial", data = data) Deviance Residuals: Min 19 Median -1.0475 -0.9731 -0.8914 30 Max 1.3445 1.5318 Coefficients: Estimate Std. Error z value Pr(>21 (Intercept) -1.03059 1.27700 -0.807 0.420
x4 0.09074 0.22708 0.400 0.689 (Dispersion parameter for binomial family taken to be 1) Null deviance: 39.429 Residual deviance: 39.269 AIC: 43.269 on 29 degrees of freedom on 28 degrees of freedom Number of Fisher Scoring iterations: 4 > exp(coefficients(fit2)) [2] x4 1.094985 > lrtest (fit2) Likelihood ratio test Model 1: y * x4 Model 2: y 1 #Df LogLik Df Chisq Pr(>Chisq) 1 2 -19.634 2. 1 -19.715 -1 0.1608 0.6885 The following critical values may be used for the questions: Xổ.05,1 = 3.841, xã.05,24 = 36.415, Xổ.05,25 = 37.652, xổ05,26 = 38.885
4.1) Write down the canonical link of logistic regression. [1 marks] 4.2) When all factors are considered as the explanatory variables, fit a logistic regression model for the data. [2 marks] 4.3) When the model is true and the sample size is large, what's the distribution of deviance? Conducting the goodness of fit test, show whether the model is good or not? [4 marks] 4.4) When one just looks at the effect of blood pressure (13) on the heart disease, show the fitted logistic regression model. Calculate the odds ratio and interpret it. [5 marks]
Min 19 Median 30 Max -1.0918 -0.9597 -0.8617 1.2999 1.6406 Coefficients: Estimate Std. Error z value Pr(>21) (Intercept) -2.870 3.418 -0.840 0.401 x3 1.753 2.552 0.687 0.492 (Dispersion parameter for binomial family taken to be 1) Null deviance: 39.429 Residual deviance: 38.944 AIC: 42.94 on 29 degrees of freedom on 28 degrees of freedom Number of Fisher Scoring iterations: 4 > exp(coefficients (fit1)) [2] x3 5.773179 > lrtest(fiti) Likelihood ratio test Model 1: yx3 Model 2: y 1 #Df LogLik Df Chisq Pr(>Chisq) 1 2 -19.472 2 1 -19.715 -1 0.485 0.4861 > fit2 <- glm(y"x4, data = data, family = 'binomial') > summary(fit2) Call: glm(formula - y - x4, family = "binomial", data = data) Deviance Residuals: Min 19 Median -1.0475 -0.9731 -0.8914 30 Max 1.3445 1.5318 Coefficients: Estimate Std. Error z value Pr(>21 (Intercept) -1.03059 1.27700 -0.807 0.420
x4 0.09074 0.22708 0.400 0.689 (Dispersion parameter for binomial family taken to be 1) Null deviance: 39.429 Residual deviance: 39.269 AIC: 43.269 on 29 degrees of freedom on 28 degrees of freedom Number of Fisher Scoring iterations: 4 > exp(coefficients(fit2)) [2] x4 1.094985 > lrtest (fit2) Likelihood ratio test Model 1: y * x4 Model 2: y 1 #Df LogLik Df Chisq Pr(>Chisq) 1 2 -19.634 2. 1 -19.715 -1 0.1608 0.6885 The following critical values may be used for the questions: Xổ.05,1 = 3.841, xã.05,24 = 36.415, Xổ.05,25 = 37.652, xổ05,26 = 38.885
4.1) Write down the canonical link of logistic regression. [1 marks] 4.2) When all factors are considered as the explanatory variables, fit a logistic regression model for the data. [2 marks] 4.3) When the model is true and the sample size is large, what's the distribution of deviance? Conducting the goodness of fit test, show whether the model is good or not? [4 marks] 4.4) When one just looks at the effect of blood pressure (13) on the heart disease, show the fitted logistic regression model. Calculate the odds ratio and interpret it. [5 marks]