summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-05-25 14:33:08 +0530
committerSuraj Yerramilli2015-05-25 14:33:08 +0530
commite7d91a07bd8a486a4eba15edbd7f063fa4f07ff7 (patch)
tree6ac08c08223b83a82616efbf0698c42428cfb3dc
parent19b98e97504a8da4396fc7545d7c3966031b2267 (diff)
downloadSysID-R-code-e7d91a07bd8a486a4eba15edbd7f063fa4f07ff7.tar.gz
SysID-R-code-e7d91a07bd8a486a4eba15edbd7f063fa4f07ff7.tar.bz2
SysID-R-code-e7d91a07bd8a486a4eba15edbd7f063fa4f07ff7.zip
minor changes in the impulse response function
-rw-r--r--R/impulse.R13
1 files changed, 6 insertions, 7 deletions
diff --git a/R/impulse.R b/R/impulse.R
index feda8bc..7ff9b34 100644
--- a/R/impulse.R
+++ b/R/impulse.R
@@ -4,25 +4,24 @@
#' given data
#'
#' @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 delay The transport delay
+#' @param M Order of the FIR Model (Default:\code{30})
+#' @param K Transport delay in the estimated impulse response
#'
#' @seealso \code{\link{plot.impulseest}}, \code{\link{step}}
#' @export
-impulseest <- function(data,lags=30){
+impulseest <- function(data,M=30,K){
N <- dim(data$output)[1]
- ind <- (lags+1):N
+ ind <- (M+1):N
- z_reg <- function(i) data$input[i:(i-lags),]
+ z_reg <- function(i) data$input[i:(i-M),]
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)
+ lags=0:M)
class(out) <- "impulseest"
return(out)
}