Standard deviation of each coefficient of regression model
15 ビュー (過去 30 日間)
古いコメントを表示
I have develop a quadratic regression model based on my data set,
such as,
y = B0 + B1X1 + B2X2 + B2X1^2 + B3X2^2
To develop this model, I use the 'fitlm' funciton. Now I have a model coefficients for each variables(B0, B1, B2, B3). I
Now I want to estimate the standard deviation of each coefficients.
Could you please share an idea how I can estimate the standard deviation of each coefficients based on the response from 'fitlm' function.
Your response will be highly appriciated.
0 件のコメント
回答 (1 件)
Jack
2023 年 3 月 26 日
Hi,
You can estimate the standard deviation of the regression coefficients using the coefCI function in MATLAB, which is available for models created using the fitlm function.
The coefCI function returns the confidence intervals for the estimated coefficients, which can be used to estimate the standard error of the coefficients by dividing the range of the confidence interval by 3.92 (for a 95% confidence interval) or 1.96 (for a 90% confidence interval).
Here's an example of how to use the coefCI function to estimate the standard deviation of the coefficients:
% generate some sample data
x1 = randn(100,1);
x2 = randn(100,1);
y = 2 + 3*x1 + 4*x2 + 1.5*x1.^2 + 2*x2.^2 + randn(100,1);
% fit the quadratic regression model
mdl = fitlm([x1 x2], y, 'quadratic');
% get the coefficients and their standard errors
coefs = mdl.Coefficients.Estimate;
[~, ~, ~, SE] = coefCI(mdl);
% calculate the standard deviation of the coefficients
SD = SE./3.92; % for a 95% confidence interval
In this example, the coefs variable contains the estimates for the coefficients, and the SE variable contains their standard errors. The SD variable contains the estimated standard deviation of each coefficient.
参考
カテゴリ
Help Center および File Exchange で Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!