diff options
author | Suraj Yerramilli | 2015-05-26 09:01:16 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-05-26 09:01:16 +0530 |
commit | c6c605030b91cdaa1851c2a3e6e431ad1d118c27 (patch) | |
tree | 09665a118f1b51bec1970fc4fe261c940658ed21 | |
parent | e3db1fea8270aadd9879fe4cf86fa0c9513d41ee (diff) | |
download | SysID-R-code-c6c605030b91cdaa1851c2a3e6e431ad1d118c27.tar.gz SysID-R-code-c6c605030b91cdaa1851c2a3e6e431ad1d118c27.tar.bz2 SysID-R-code-c6c605030b91cdaa1851c2a3e6e431ad1d118c27.zip |
Added code to compute standard errors
-rw-r--r-- | R/impulse.R | 8 |
1 files 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) } |