How to obtain residuals after using 'fitrm'?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello,
I have been trying to obtain the residuals after using 'fitrm' with this formula: 'VarLeft-VarRight~Group', so that I can test for normality and outliers, but I haven't found a way of doing this on MATLAB. I was wondering if anybody knows how to do this?
Thanks!
댓글 수: 0
답변 (1개)
dpb
2024년 9월 23일
It doesn't seem as they have implemented it directly; you'll have to compute the residuals as the difference between the resulting model prediction and the input data at the desired data points...
There's an example for the Fisher iris data set that doesn't specifically compute the residuals themselves, but calculates the predicted values and plots them in comparison to the input data...just follow its lead...
load fisheriris
t = table(species,meas(:,1),meas(:,2),meas(:,3),meas(:,4), ...
'VariableNames',{'species','meas1','meas2','meas3','meas4'});
Meas = dataset([1 2 3 4]','VarNames',{'Measurements'});
rm = fitrm(t,'meas1-meas4~species','WithinDesign',Meas);
Yhat=predict(rm,t([1 51 101],:))
Y=t([1 51 101],[2:end])
Res=Y-Yhat
Use your data a results similarly...
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!