From c6c605030b91cdaa1851c2a3e6e431ad1d118c27 Mon Sep 17 00:00:00 2001 From: Suraj Yerramilli Date: Tue, 26 May 2015 09:01:16 +0530 Subject: Added code to compute standard errors --- R/impulse.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/impulse.R b/R/impulse.R index ca60c04..716c279 100644 --- a/R/impulse.R +++ b/R/impulse.R @@ -29,13 +29,13 @@ impulseest <- function(data,M=30,K=0){ # Fit Linear Model and find standard errors fit <- lm(Y~Z-1) - #df <- nrow(Z)-ncol(Z);sigma2 <- resid(fit)^2/df - #vcov <- sigma2 * inv(t(Z)*Z) - #se <- sqrt(diag(vcov)) + df <- nrow(Z)-ncol(Z);sigma2 <- sum(resid(fit)^2)/df + vcov <- sigma2 * solve(t(Z)%*%Z) + se <- sqrt(diag(vcov)) out <- list(coefficients=coef(fit),residuals=resid(fit),lags=K:(M+K), - x=colnames(data$input),y=colnames(data$output)) + x=colnames(data$input),y=colnames(data$output),se = se,df=df) class(out) <- "impulseest" return(out) } -- cgit