How to run logistic regression with state variables?

3 views (last 30 days)
I am trying to run a logistic regression analysis of default/non-default for coporate bonds,
prob of default = 1/(1+exp(-f(x)), f(x) = b0 + b1*x1 + b2*x2
x1 (Dist_to_DFLT) is a continouse variable, and x2 (CreditStateCategory) is a state variable with 4 different states. I am following the example here to fit a Logistic Regression model.
My code is:
modelspec1 = 'DefaultFlag ~ Dist_to_DFLT*CreditStateCategory - Dist_to_DFLT:CreditStateCategory';
mdl1 = fitglm(Analytics_Data_AllPeriods_Train,modelspec1,'Distribution','binomial')
And the output is:
mdl1 =
Generalized linear regression model:
logit(DefaultFlag) ~ 1 + Dist_to_DFLT + CreditStateCategory
Distribution = Binomial
Estimated Coefficients:
Estimate SE tStat pValue
________ ________ _______ __________
(Intercept) -1.5476 0.031128 -49.716 0
Dist_to_DFLT -1.2886 0.017317 -74.411 0
CreditStateCategory_Expansion 0.074652 0.045428 1.6433 0.10032
CreditStateCategory_Recovery -0.86881 0.058402 -14.876 4.703e-50
CreditStateCategory_Repair -0.97184 0.084661 -11.479 1.6794e-30
169282 observations, 169277 error degrees of freedom
Dispersion: 1
Chi^2-statistic vs. constant model: 8e+03, p-value = 0
My question is why my regression model doesn't generate the cross-terms like: Sex*Age, Sex*Weight, Age*Weight etc?
mdl =
Generalized linear regression model:
logit(Smoker) ~ 1 + Sex*Age + Sex*Weight + Age*Weight
Distribution = Binomial

Accepted Answer

the cyclist
the cyclist on 11 Apr 2024
When you specified the model as
modelspec1 = 'DefaultFlag ~ Dist_to_DFLT*CreditStateCategory - Dist_to_DFLT:CreditStateCategory'
the "subtracted" term
'- Dist_to_DFLT:CreditStateCategory'
is explicitly removing the cross term.
It seems that you actually intended
modelspec1 = 'DefaultFlag ~ Dist_to_DFLT*CreditStateCategory'

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!