Panel data regression comparison

5 次查看(过去 30 天)
Nick
Nick 2022-3-25
回答: Sai Pavan 2023-10-20
I have a very large panel data and would like to apply a number of simple machine learning techniques (Logistic Regression, Decision Trees, Bagged Trees).
During my preparation I came across fitglm and fitLifetimePDModel, the latter of which is meant to capture panel data. I was trying to understand how/if that differs from fitglm because when I try the below, the results are exactly the same. Is that right?
Why is that? For example, under fitglm I'm not telling the program that each customer can have more than one data points.
Thank you
load RetailCreditPanelData.mat
pdModel_1 = fitLifetimePDModel(data,"Logistic", 'AgeVar','YOB', 'IDVar','ID', 'LoanVars','ScoreGroup','ResponseVar','Default');
disp(pdModel_1.Model)
pdModel_2 = fitglm(data,'Default ~ 1 + ScoreGroup + YOB', 'Distribution','binomial', 'link', 'logit');
disp(pdModel_2)

回答(1 个)

Sai Pavan
Sai Pavan 2023-10-20
Hi Nick,
I understand that you are trying to learn the difference between “fitglm” and “fitLifetimePDModel” functions and want to know why the functions are producing same results.
  • The fitLifetimePDModel function is specifically designed to handle panel data for lifetime models, where each observation represents a customer with multiple data points over time considering the dependence and correlation among the observations within each individual when fitting the model.
  • On the other hand, fitglm is a more general function for fitting generalized linear models, including logistic regression and Poisson regression, treating each observation as independent, without considering any panel structure.
  • The reason for the results to be exactly same is that both fitLifetimePDModel and fitglm use logistic regression with the same link function (logit) and distribution (binomial) when fitting the model. In your fitglm” function call, you explicitly specified the logistic regression formula, which matches the formula used by fitLifetimePDModel. Therefore, the resulting models are identical.
Please refer to the below documentation to learn more about fitglm” and “fitLifetimePDModel” functions:
Hope it helps.
Regards,
Sai Pavan

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by