![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/362848/image.png)
glmfit not working: US's chances of recession
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pedro Alves
el 18 de Sept. de 2020
Comentada: Star Strider
el 19 de Sept. de 2020
close all
A=[ind us2y10 rec];
X=[ind us2y10];
[logitCoef] = glmfit(X,rec,'binomial','link','logit');
yfit=[ones(359,1) X]*logitCoef;
plot(yfit);
Hello everyone!
I'm trying to estimate a logit model for the probability of recession in the US, based on a constante factor, the inddustrial production and US yield curve slope for 2y and 10y. The results are not the one supposed to be, since the model is presenting out of bounds ([0,1]) estimates.
Thanks in advance for your time in checking the script.
Cheers,
Pedro
0 comentarios
Respuesta aceptada
Star Strider
el 19 de Sept. de 2020
T1 = readtable('USREC.xls');
ind = T1.ind;
us2y10 = T1.us2y10;
rec = T1.rec;
X=[ind us2y10];
logitCoef = glmfit(X,rec,'binomial','link','logit');
yfit = glmval(logitCoef,X,'logit');
figure
plot(X(:,1), yfit);
grid
xlabel('ind')
ylabel('‘rec’ Fit')
sortX = sortrows(X,1) % Sort ‘X’ First
yfit = glmval(logitCoef,sortX,'logit');
figure
plot(sortX(:,1), yfit); % Cleaner-Looking Plot
grid
xlabel('ind')
ylabel('‘rec’ Fit')
producing this plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/362848/image.png)
I am not certain what you are doing, or how to interpret this, however this plot appears to meet the [0,1] criterion.
.
4 comentarios
Star Strider
el 19 de Sept. de 2020
As always, my pleasure!
I appreciate the reference. I will consider getting the book for my library, since I could certainly benefit from such a source.
Más respuestas (0)
Ver también
Categorías
Más información sobre Descriptive Statistics en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!