regress with vectors arguments
显示 更早的评论
Hello,i know that in regress we make an estimation of our data using some other vector.
In here We have estimation of two data simultaniosly m10 and m5 as shown in the code bellow.
BINT are the intervals of B ,R are the residuals.
I have an output shown bellow.
B has only two values(one for each data vector)
so i think my estimate for m10 is b[1]*v1 and m5 is b[2]*v2
Why B size is 2X1 but R is 10 values,
I cant link visually R,Bint values to the B vector(there is a size mismatch between them).can i somehow visualize the connection between R,Bint values and my coeffient B vector values ?
Thanks.

e=0.001;
T=10;
eT=e*T;
coeff_1 = 0.05;
coeff_2 = 0.07;
n=5;
m10 = 2*eT+3*e + coeff_1*randn(n,1);
m5 = 4*eT+5*e + coeff_2*randn(n,1);
v1=repmat([2,3],n,1);
v2=repmat([4,5],n,1)];
[B,BINT,R] = regress([m10;m5],[v1;v2]);
回答(1 个)
Star Strider
2020-3-5
0 个投票
‘Why B size is 2X1 but R is 10 values’
As I understand your Question, it is because ‘B’ is a (coefficient) vector of parameters, and you are only fitting two colums. There will be one ‘B’ parameter for each column. If you add a third ones column (to specify the intercept) there would be three ‘B’ values (and a more accurate regression).
4 个评论
fima v
2020-3-6
Star Strider
2020-3-6
The residuals are the differencew between the fitted curve (requiring two parameters) and the data (apparently comprising 10 elements).
fima v
2020-3-6
Star Strider
2020-3-6
The regress funciton will do all that for you. See Determine Significance of Linear Regression Relationship, and for confidence intervals on the regression, use fitlm and predict.
You can of course code all these yourself. I do not recommend that.
类别
在 帮助中心 和 File Exchange 中查找有关 Linear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!