Standard deviation of each coefficient of regression model
11 次查看(过去 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!