summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-05-25 18:37:19 +0530
committerSuraj Yerramilli2015-05-25 18:37:19 +0530
commitf1b4017b0f0e07dfa8e24c14834af49bb71c4a3f (patch)
tree806af749fcc467c7a7ffd99859937b13156c41f8
parent177dd0536ea9da096aab481a18914c97cee925a0 (diff)
downloadSysID-R-code-f1b4017b0f0e07dfa8e24c14834af49bb71c4a3f.tar.gz
SysID-R-code-f1b4017b0f0e07dfa8e24c14834af49bb71c4a3f.tar.bz2
SysID-R-code-f1b4017b0f0e07dfa8e24c14834af49bb71c4a3f.zip
Basic features added
-rw-r--r--R/impulse.R18
-rw-r--r--man/impulseest.Rd5
2 files changed, 14 insertions, 9 deletions
diff --git a/R/impulse.R b/R/impulse.R
index 2066c4f..fccce3d 100644
--- a/R/impulse.R
+++ b/R/impulse.R
@@ -5,23 +5,24 @@
#'
#' @param data an object of class \code{idframe}
#' @param M Order of the FIR Model (Default:\code{30})
-#' @param K Transport delay in the estimated impulse response
+#' @param K Transport delay in the estimated impulse response
+#' (Default:\code{0})
#'
#' @seealso \code{\link{plot.impulseest}}, \code{\link{step}}
#' @export
-impulseest <- function(data,M=30,K){
+impulseest <- function(data,M=30,K=0){
N <- dim(data$output)[1]
- ind <- (M+1):N
+ ind <- (M+K+1):N
- z_reg <- function(i) data$input[i:(i-M),]
+ z_reg <- function(i) data$input[(i-K):(i-M-K),]
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:M)
+ out <- list(coefficients=coef(fit),residuals=resid(fit),lags=K:M+K,
+ x=colnames(data$input),y=colnames(data$output))
class(out) <- "impulseest"
return(out)
}
@@ -35,7 +36,10 @@ impulseest <- function(data,M=30,K){
#' @seealso \code{\link{impulseest}},\code{\link{step}}
#' @export
plot.impulseest <- function(model){
- plot(model$lags,coef(model),type="h");abline(h=0)
+ title <- paste("Impulse Response \n From",model$x,"to",model$y)
+ plot(model$lags,coef(model),type="h",xlab="Lag",ylab= model$y,
+ main = title)
+ abline(h=0)
}
diff --git a/man/impulseest.Rd b/man/impulseest.Rd
index c831cc3..7d36f99 100644
--- a/man/impulseest.Rd
+++ b/man/impulseest.Rd
@@ -4,14 +4,15 @@
\alias{impulseest}
\title{Estimate Impulse Response Models}
\usage{
-impulseest(data, M = 30, K)
+impulseest(data, M = 30, K = 0)
}
\arguments{
\item{data}{an object of class \code{idframe}}
\item{M}{Order of the FIR Model (Default:\code{30})}
-\item{K}{Transport delay in the estimated impulse response}
+\item{K}{Transport delay in the estimated impulse response
+(Default:\code{0})}
}
\description{
\code{impulseest} is used to estimate impulse response models in the