NaNin 线性时间序列回归
NaNin a linear time series regression
假设我有三个时间序列:
y <- c(7, 8, 9, 2, 4, 5, 9, 4)
x <- c(9, 3, 5, 2, 7, 1, 6, 1) and
z <- c(NaN, NaN, NaN, 9, 10, 3, 5, 3)
现在我想用 R 计算以下回归:reg1 <- lm(y~x+z)
然后 summary(reg1)
给出以下输出:
Call:
lm(formula = y ~ x + z)
Residuals:
ALL 3 residuals are 0: no residual degrees of freedom!
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.2414 NA NA NA
x 0.5172 NA NA NA
z -0.5862 NA NA NA
Residual standard error: NaN on 0 degrees of freedom
(3 observations deleted due to missingness)
Multiple R-squared: 1, Adjusted R-squared: NaN
F-statistic: NaN on 2 and 0 DF, p-value: NA
所以看起来,系数是估计的,但是 t 值的 none 等。我的问题是,1) 为什么没有错误消息和 2) 我如何省略 NaN从回归中,所以 R 给我 t 值等?谢谢
输出实际上回答了这个问题:
ALL 3 residuals are 0: no residual degrees of freedom!
所以没有剩余的自由度来估计缺失的输出。使用此公式,至少需要 4 行非缺失数据才能估算缺失数量。
假设我有三个时间序列:
y <- c(7, 8, 9, 2, 4, 5, 9, 4)
x <- c(9, 3, 5, 2, 7, 1, 6, 1) and
z <- c(NaN, NaN, NaN, 9, 10, 3, 5, 3)
现在我想用 R 计算以下回归:reg1 <- lm(y~x+z)
然后 summary(reg1)
给出以下输出:
Call:
lm(formula = y ~ x + z)
Residuals:
ALL 3 residuals are 0: no residual degrees of freedom!
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.2414 NA NA NA
x 0.5172 NA NA NA
z -0.5862 NA NA NA
Residual standard error: NaN on 0 degrees of freedom
(3 observations deleted due to missingness)
Multiple R-squared: 1, Adjusted R-squared: NaN
F-statistic: NaN on 2 and 0 DF, p-value: NA
所以看起来,系数是估计的,但是 t 值的 none 等。我的问题是,1) 为什么没有错误消息和 2) 我如何省略 NaN从回归中,所以 R 给我 t 值等?谢谢
输出实际上回答了这个问题:
ALL 3 residuals are 0: no residual degrees of freedom!
所以没有剩余的自由度来估计缺失的输出。使用此公式,至少需要 4 行非缺失数据才能估算缺失数量。