Quantile Regression - Plot is odd
1 回表示 (過去 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.

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 件)
参考
カテゴリ
Help Center および File Exchange で Linear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!