Linear Regression with Dummy Interaction
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I am looking to estimate a linear regression in the following manner:
I want to estimate
(a constant), the μ, and the ζ. I have coded both dummies as NxN matrixes containing 1 or 0 in the diagonal depending on the specif year, P(t),P(t-1) and A are vectors of length N.
I have tried to use fitlm by creating a table with all imputs.
fit2 = fitlm(tbl,'p~ d1+d2*pre_p+prod');
My error is the following:
"Predictor variables must be numeric vectors, numeric matrices, or categorical vectors."
I know that the issue lies in the coding of the dummy variable. My question is about implementation.
Thanks !
8 Kommentare
Peter Perkins
am 28 Jul. 2021
If you use a categorical variable as a predictor in your model, fitlm will create dummy variables internally. I'm suire there are examples in the doc. You don't need to create dummy vars unless you want some non-standard coding. Maybe that's what you want. If so, creatre LOGICAL or NUMERIC dummy variables yourself. Based on the limited information you have provided, it appears that maybe you have been creating categorrical dummy variables.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Analysis of Variance and Covariance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

