From 963d1e08f2448f75d4567f2c461862a60ebfc112 Mon Sep 17 00:00:00 2001 From: jonlachmann Date: Fri, 25 Mar 2022 18:14:19 +0100 Subject: [PATCH] Change .fecov to remove multiple unnecessary calls to summary.lm. The function summary.lm is rather complex, and there is no need to call it when we just require the degrees of freedom. This change removes that call and saves some computational complexity. --- R/internal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/internal.R b/R/internal.R index 254524f..2902b58 100644 --- a/R/internal.R +++ b/R/internal.R @@ -5,7 +5,7 @@ require(strucchange) ## ".fecov" <- function(x, n.ahead) { - n.par<-sapply(x$varresult, function(x) summary(x)$df[2]) + n.par <- sapply(x$varresult, function (res) x$obs - length(res$coefficients)) sigma.u <- crossprod(resid(x))/n.par Sigma.yh <- array(NA, dim = c(x$K, x$K, n.ahead)) Sigma.yh[, , 1] <- sigma.u