Multivariate GLMFIT and GLMVAL
Ältere Kommentare anzeigen
I have a problem with plotting the results of a glm model with several predictors.
I first fit the model with GLMFIT as:
[b,dev,stats]= glmfit(x, y, distr);
where 'x' is a matrix of N observations by M predictors, and 'y' a vector of observed responses.
Then I produce predictions as:
xpred= zeros(100,size(x,2));
for k= 1:size(x,2)
xpred(:,k)= linspace(min(x(:,k)),max(x(:,k)),100);
end
ypred= glmval(b,xpred,link,stats);
Then I want to plot the effect of each individual predictor on the response variable as:
for j= 1:size(x,2)
figure(j);
plot(x(:,j),y,'k.',xpred(:,j),ypred,'b-','LineWidth',1)
end
But the line (predicted values) for most of the predictors goes totally out of the cloud of observed values. Am I doing something totally wrong or is just that the fit is poor? Any help would be much appreciated. Thanks
Akzeptierte Antwort
Weitere Antworten (2)
Peter Perkins
am 19 Jan. 2012
0 Stimmen
Francisco, it's pretty hard to say what's happening without knowing anything about the data or the model, but this may be an artifact of the way you've created xpred. Notice that the first row of xpred has the min values for all of the predictors, and the last row has the max values. You've created what is essentially a straight line through the design variable space that may or may not have anything to do with the actual cloud of points in your data. That could explain why ypred doesn't look much like y.
Hope this helps.
Francisco de Castro
am 20 Jan. 2012
Kategorien
Mehr zu Classification Learner App finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!