NaNin线性时间序列回归

时间:2015-04-10 09:56:46

标签: r time-series

说我有三个时间序列:

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值等。我的问题是,1)为什么没有错误信息和2)如何从回归中省略NaNs,所以R给我t值等?感谢

1 个答案:

答案 0 :(得分:2)

输出实际上回答了这个问题:

  

所有3个残差为0:没有剩余自由度!

所以没有剩余的自由度来估计缺失的输出。使用此公式,至少需要4行非缺失才能估计缺失的数量。