How to calculate error in trend?
4 次查看(过去 30 天)
显示 更早的评论
I have estimated slope from least square method. Now I need to calculate error of this slope at 95% confidence interval. kindly suggest me a MATLAB code in this regard. I'll be thankful remaining you.
1 个评论
Brendan Hamm
2015-5-12
编辑:Brendan Hamm
2015-5-12
Are you using the fitlm function in the Statistics and Machine Learning Toolbox or polyfit/ polyval? Please provide an example of what you have done, so that it is easier to help you.
回答(1 个)
Star Strider
2015-5-12
If you used another method, you need to specify the function or other code you used. It is not possible to answer your Question otherwise.
4 个评论
Star Strider
2015-5-13
Unfortunately, regress is not going to give you the covariance matrix, and you need it to compute the standard errors. I would use fitlm instead, since it will give you the output you want.
If you must use regress, you can calculate the standard errors as:
x = randi(10, 10, 1); % Create Data
y = randi(100, 10, 1); % Create Data
X = [ones(10,1) x]; % Design Matrix
[b,bint,r,rint,stats] = regress(y,X); % Estimate Parameters
rvar = r'*r/(size(X,1)-length(b)); % Residual Variance
covb = rvar./(X'*X); % Covariance Matrix
SE = sqrt(diag(covb)); % Standard Errors
That would be the same for the ‘covb’ field of the ‘stats’ structure returned by robustfit.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!