如果我有数据框x
x = data.frame(y1 = c(1, 5, 8, 9, 10, 0, NA),
y2 = c(2, 6, 9, 0, 1, 7, NA),
x1 = c(3, 5, -8, 2, 5, 11, 12),
x2 = c(0, 1, 2, 8, 0, 1, 12),
x3 = 1:7)
并且发现y1
的最佳回归依赖于y2
,反之亦然,使得:
fit1 = lm(y1 ~ y2 + x1, data = x[1:6, ])
fit2 = lm(y2 ~ y1 + x2 + x3, data = x[1:6, ])
如何为第七次观测得出y1
和y2
的预测?