In: Statistics and Probability
Complete the R code using Rstudio so that it calculates and returns the estimates of β, the intercept and regression weight of the logistic regression of approximate GPA on Rouder-Srinivasan preference.
## Data Preference <- c( 0, 0, 0, 0, 0, 1, 1, 1, 1) # 0: Rouder; 1: Srinivasan GPA <- c(2.0, 2.5, 3.0, 3.5, 4.0, 2.5, 3.0, 3.5, 4.0) Count <- c( 4, 5, 21, 22, 8, 2, 1, 4, 7) # Define the deviance function deviance <- function(beta) { ... complete this ... } ## Test the function deviance(c(0,1)) ## Estimate optim(c(0, 1), deviance)$par
The attach images details solution solved in R-studion software given below.
1.
2.
Conclusion:
Null Deviance: 12.37
Residual Deviance: 2.558e-09
Lower the value of AIC=6 better the model
Deviance is a measure of goodness of fit of a model. Higher numbers always indicates bad fit. The null deviance shows how well the response variable is predicted by a model that includes only the intercept (grand mean) where as residual with inclusion of independent variables