IniziaInizia gratis

Model specification and estimation

You have seen the glm() command for running a logistic regression. glm() stands for generalized linear model and offers a whole family of regression models.

Take the exercise dataset for this coding task. The data defaultData you need for this exercise is available in your environment and ready for modeling.

Questo esercizio fa parte del corso

Machine Learning for Marketing Analytics in R

Visualizza il corso

Istruzioni dell'esercizio

  • Use the glm() function in order to model the probability that a customer will default on his payment by using a logistic regression. Include every explanatory variable of the dataset and specify the data that shall be used.
  • Do not forget to specify the argument family.
  • Extract the coefficients from the model, then transform them to the odds ratios and round.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Build logistic regression model
logitModelFull <- ___(PaymentDefault ~ limitBal + sex + education + marriage +
                   age + pay1 + pay2 + pay3 + pay4 + pay5 + pay6 + billAmt1 + 
                   billAmt2 + billAmt3 + billAmt4 + billAmt5 + billAmt6 + payAmt1 + 
                   payAmt2 + payAmt3 + payAmt4 + payAmt5 + payAmt6, 
                family = ___, data = ___)

# Take a look at the model
___(logitModelFull)

# Take a look at the odds ratios
coefsexp <- ___(logitModelFull) %>% ___ %>% round(2)
coefsexp
Modifica ed esegui il codice