Quantile Regression - Plot is odd
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I am applying (experimentally, for now) quantile regression on my data, as they have violated both normality of residuals and homogeneity of variances with Levene's tests using linear regression.
Following the example from the documentation, I am unable to retrieve a proper line. Please fine the code below, as well as the plot and compare with the plot given in the documentation page.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/202878/image.png)
rng(1);
QRMdl = TreeBagger(100,X,Y,'Method','regression');
qrPred = quantilePredict(QRMdl,X);
LSMdl = fitlm(X,Y);
figure;
plot(X,Y,'o');
h = gca;
xlim = h.XLim';
hl = legend('Data');
title('Quantile Regression')
hold on;
plot(xlim,[ones(2,1) xlim]*LSMdl.Coefficients.Estimate,'LineWidth',2);
hl.String{2} = 'Linear Regression';
hold on;
plot(X,qrPred,'LineWidth',1);
hl.String{3} = 'Quantile Line';
hold off;
I also wanted to ask, if you want to add an independent variable (group) in the above method (X is a covariate, Y are the data). How would I add the independent variable to X? As an extra column, by multiplying it by X or by using a different approach? Essentially, I am interested in the interaction between the group and the covariate.
Any help would be appreciated.
댓글 수: 0
답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!