Michael B
Michael B

Reputation: 257

NaNin a linear time series regression

Say I have three 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)

Now I want to compute the following regression with R: reg1 <- lm(y~x+z) then summary(reg1)gives me the following output:

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

So it seems, that the coefficients are estimated, but none of the t- values etc. My question here is, 1) why is there no error message and 2) how can I omit the NaNs from the regression, so R gives me t- values etc? Thanks

Upvotes: 0

Views: 177

Answers (1)

G. Grothendieck
G. Grothendieck

Reputation: 269694

The output actually answers this:

ALL 3 residuals are 0: no residual degrees of freedom!

so there are no residual degrees of freedom to estimate the missing outputs. With this formula, at least 4 rows of non-missings will be needed in order to get estimates of the missing quantities.

Upvotes: 2

Related Questions