summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2016-02-24 15:24:35 +0530
committerSuraj Yerramilli2016-02-24 15:24:35 +0530
commit86d972f8c572752f047012647af0bdf54d6de33d (patch)
tree34011a8b9d2965a35cd6b59ce2d61028feb4bec3
parent90f37efac810fbdde5166b9bd1bdbff1b251c8a1 (diff)
downloadSysID-R-code-86d972f8c572752f047012647af0bdf54d6de33d.tar.gz
SysID-R-code-86d972f8c572752f047012647af0bdf54d6de33d.tar.bz2
SysID-R-code-86d972f8c572752f047012647af0bdf54d6de33d.zip
changing plottting engine to ggplot2
-rw-r--r--R/nonparam.R24
1 files changed, 15 insertions, 9 deletions
diff --git a/R/nonparam.R b/R/nonparam.R
index 3e6d2c0..b637aa4 100644
--- a/R/nonparam.R
+++ b/R/nonparam.R
@@ -129,19 +129,25 @@ plot.impulseest <- function(model,sig=0.975){
#' fit <- impulseest(data)
#' step(fit)
#'
+#' @import ggplot2
#' @export
step <- function(model){
- par(mfrow=c(model$noutputs,model$ninputs))
+ plotseq <- seq(model$noutputs*model$ninputs)
+ g <- vector("list",model$nin*model$nout)
- stepplot <- function(model){
- title <- paste("Step Response \n From",model$x,"to",model$y)
- stepResp <- cumsum(coef(model))
- plot(model$lags,stepResp,type="s",xlab="Lag",ylab= model$y,
- main = title)
- abline(h=0)
+ for(i in plotseq){
+ z <- model[[i]]
+ stepResp <- cumsum(coef(z))
+ yindex <- (i-1)%/%model$nin + 1;uindex <- i-model$nin*(yindex-1)
+ df <- data.frame(x=z$lags,y=stepResp)
+ g[[i]] <- ggplot(df,aes(x,y))+
+ geom_step() + ggtitle(paste("From",z$x,"to",z$y)) +
+ theme_bw(14) + ylab(ifelse(uindex==1,"Step Response","")) +
+ xlab(ifelse(yindex==model$nout,"Lags","")) +
+ theme(axis.title=element_text(size=12,color = "black",face = "plain"),
+ title=element_text(size=9,,color = "gray",face="bold"))
}
- l <- model[seq(model$noutputs*model$ninputs)]
- p <- lapply(l,stepplot)
+ multiplot(plotlist=g,layout=plotseq)
}
#' Estimate frequency response