Multivariate GLMFIT and GLMVAL
이전 댓글 표시
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
채택된 답변
추가 답변 (2개)
Peter Perkins
2012년 1월 19일
0 개 추천
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
2012년 1월 20일
카테고리
도움말 센터 및 File Exchange에서 Classification Learner App에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!