フィルターのクリア

Quantile Regression - Plot is odd

3 ビュー (過去 30 日間)
LM_BU
LM_BU 2019 年 2 月 5 日
編集済み: LM_BU 2019 年 2 月 5 日
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 件)

製品


リリース

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by