【发布时间】:2023-06-27 10:38:01
【问题描述】:
如果给我一个线性回归模型的输出:
Call:
lm(formula = Cost ~ Age + I(Age^2))
Residuals:
Min 1Q Median 3Q Max
-371.76 -218.77 -70.16 141.97 541.08
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 348.088 214.816 1.620 0.127
Age 103.003 181.969 0.566 0.580
I(Age^2) 4.713 29.248 0.161 0.874
Residual standard error: 293.2 on 14 degrees of freedom
Multiple R-squared: 0.478,Adjusted R-squared: 0.4035
F-statistic: 6.411 on 2 and 14 DF, p-value: 0.01056
我将如何仅据此计算置信区间?
基本上我希望手动计算以下内容:
> confint(model.fit, level = 0.90)
5 % 95 %
(Intercept) -30.26946 726.44545
Age -217.50106 423.50653
I(Age^2) -46.80263 56.22808
【问题讨论】:
-
到目前为止您尝试过什么?
coef(summary(fitted_model))将为您提供一个包含Estimate和Std. Error(以及其他)列的表格。qt(c(0.05, 0.95), df = df.residual(fitted_model))将为您提供q所需的乘数est ± q*std.err... -
你能提供一些示例数据,或者你的数据结构使用'dput(yourdata)`吗?
-
请提供足够的代码,以便其他人更好地理解或重现问题。
标签: r math statistics linear-regression confidence-interval