How to obtain residuals after using 'fitrm'?
4 次查看(过去 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!