这是我的数据:
a <- c(60, 65, 70, 75, 80, 85, 90, 95, 100, 105)
b <- c(26, 24.7, 20, 16.1, 12.6, 10.6, 9.2, 7.6, 6.9, 6.9)
a_b <- cbind(a,b)
plot(a,b, col = "purple")
abline(lm(b ~ a),col="red")
reg <- lm(b ~ a)
Run Code Online (Sandbox Code Playgroud)
我想使用 predict 函数来计算 110 处预测 b 值的标准误差。
z <- predict(reg, newdata=data.frame(year=110), se.fit=TRUE)
Run Code Online (Sandbox Code Playgroud)
这是我得到的输出,但我认为这只是给了我 10 个时间点的标准误差,而不是新的第 11 个数据点:
z
$fit
1 2 3 4 5 6 7 8 9 10
24.456364 22.146061 19.835758 17.525455 15.215152 12.904848 10.594545 8.284242 5.973939 3.663636
$se.fit …Run Code Online (Sandbox Code Playgroud)