diff options
author | Suraj Yerramilli | 2015-05-25 07:52:03 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-05-25 07:52:03 +0530 |
commit | 19b98e97504a8da4396fc7545d7c3966031b2267 (patch) | |
tree | e8908021b0fd2ddc190fab92ca4461a26a781ee6 /R/impulse.R | |
parent | fbb5a731b240ed64fbbb020e2567149960c00551 (diff) | |
download | SysID-R-code-19b98e97504a8da4396fc7545d7c3966031b2267.tar.gz SysID-R-code-19b98e97504a8da4396fc7545d7c3966031b2267.tar.bz2 SysID-R-code-19b98e97504a8da4396fc7545d7c3966031b2267.zip |
added basic impulse response estimation for SISO systems
Diffstat (limited to 'R/impulse.R')
-rw-r--r-- | R/impulse.R | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/R/impulse.R b/R/impulse.R index e5de722..feda8bc 100644 --- a/R/impulse.R +++ b/R/impulse.R @@ -6,14 +6,25 @@ #' @param data an object of class \code{idframe} #' @param lags The number of lags upto which the estimate is to be #' calculated. (Default:\code{30}) -#' @param conf The confidence interval +#' @param delay The transport delay #' -#' @seealso \code{\link{impulse}}, \code{\link{step}} +#' @seealso \code{\link{plot.impulseest}}, \code{\link{step}} #' @export impulseest <- function(data,lags=30){ - - z_reg <- function(i) data$input[i:(i-lags)] - Z <- t(sapply()) + + N <- dim(data$output)[1] + ind <- (lags+1):N + + z_reg <- function(i) data$input[i:(i-lags),] + Z <- t(sapply(ind,z_reg)) + Y <- data$output[ind,] + + fit <- lm(Y~Z-1) + + out <- list(coefficients=coef(fit),residuals=resid(fit), + lags=0:lags) + class(out) <- "impulseest" + return(out) } #' Impulse Response Plots @@ -24,8 +35,8 @@ impulseest <- function(data,lags=30){ #' #' @seealso \code{\link{impulseest}},\code{\link{step}} #' @export -impulse <- function(model){ - +plot.impulseest <- function(model){ + plot(model$lags,coef(model),type="h");abline(h=0) } |