How do I extend the confidence boundaries of fitlm? Also help with general confidence boundaries of Least Squares?

12 visualizaciones (últimos 30 días)
I am not as experienced with stats as I'd like to be, so unfortunately I don't know too much about fitting confidence bounds, how they are calculated and whether I'm after an observational/ functional or simultaneous/ non-simultaneous or not; I'd like to, but for now I really just need to get these confidence bounds on a plot I need for uni.
I can't figure out how to calculate them in time, nor can I seem to find any resources about the boundaries of a linear regression method in matlab, so I just want to ask here: How do I extend the bounds plotted using the fitlm() function?
I have a model, 'mdl3', which is superimposed on the data itself using "hold on" followed by "plot(mdl3)". The entire point of this regression model is specifically to measure the x-intercept, so although it is useful having the bounds there to graphically demonstrate the fit, it would be ideal if I could extrapolate them all the way to the edge(s) of the axis limit(s). I understand, from my recent scowering, that the default boundaries are likely "simultaneous"; meaning, from my vague understanding, this is not intended for extrapolation: In this case, would it be possible to just superimpose another, non-simultanous, confidence boundary?
P.S.: As you may have read, I also need results for the uncertainty of the x-intercept, and this is also an aspect I am rather light on (I had to drop out of first year stats due to illness and haven't managed to catch up yet). I am using the taylor series approximation, using the "*.CoefficientCovariance(1,2)" as the value; if there is a better method/ inbuilt matlab function, I'd greatly appreciate that as well. Cheers!

Respuestas (1)

John D'Errico
John D'Errico el 16 de Jun. de 2020
You needed to scower more.
  1. Plotting the result of a call to fitlm then uses predict to compute confidence intervals when plotted.
  2. Reading the help for predict, by default the confidence intervals are NON-simultaneous.
  3. If you look at the code for LinearModel/plot (do NOT edit the code, use type instead) you will see the call to predict did NOT specify a change from the default.
Oh. "Simultaneous" does not indicate whether extrapolation is intended. Extrapolation of confidence intervals is probably a really bad idea anyway you would do it.
>> N = 25;
>> x = rand(N,1);
>> y = randn(size(x)) + x;
>> mdl = fitlm(x,y)
mdl =
Linear regression model:
y ~ 1 + x1
Estimated Coefficients:
Estimate SE tStat pValue
_________________ _________________ _________________ ___________________
(Intercept) -0.51960353138985 0.351018534063917 -1.48027377749585 0.152369194934559
x1 1.76582214020889 0.620664611608085 2.84505046233232 0.00916753871041665
Number of observations: 25, Error degrees of freedom: 23
Root Mean Squared Error: 0.915
R-squared: 0.26, Adjusted R-Squared: 0.228
F-statistic vs. constant model: 8.09, p-value = 0.00917
>> xci = linspace(-.5,1.5)';
>> [ypred,yci] = predict(mdl,xci,'simul',true);
>> plot(mdl)
>> hold on
>> plot(xci,yci,'g-')

Community Treasure Hunt

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

Start Hunting!

Translated by