summaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorSuraj Yerramilli2017-01-06 11:52:09 -0600
committerSuraj Yerramilli2017-01-06 11:52:09 -0600
commitba6f9216f1f0e8dad97c3e713182f05b8537a171 (patch)
tree0494124c59f01b782a15f203d706c0b35f381362 /R
parent1fd2aeb8c4b8e884a69ecef170dfe6e09d7d7a11 (diff)
downloadSysID-R-code-ba6f9216f1f0e8dad97c3e713182f05b8537a171.tar.gz
SysID-R-code-ba6f9216f1f0e8dad97c3e713182f05b8537a171.tar.bz2
SysID-R-code-ba6f9216f1f0e8dad97c3e713182f05b8537a171.zip
global bindings part 2
Diffstat (limited to 'R')
-rw-r--r--R/estpoly.R7
-rw-r--r--R/idframe.R10
2 files changed, 9 insertions, 8 deletions
diff --git a/R/estpoly.R b/R/estpoly.R
index f18646f..5d5de76 100644
--- a/R/estpoly.R
+++ b/R/estpoly.R
@@ -110,8 +110,8 @@ plot.estpoly <- function(model,newdata=NULL){
titstr <- "Predictions of Model on Test Set"
}
df <- data.frame(Predicted=ypred,Actual=yact,Time=time)
- ggplot(df, aes(x = Actual,y=Predicted)) + ggtitle(titstr) +
- geom_abline(intercept=0,slope=1,colour="#D55E00") + geom_point()
+ with(df,ggplot(df, aes(x = Actual,y=Predicted)) + ggtitle(titstr) +
+ geom_abline(intercept=0,slope=1,colour="#D55E00") + geom_point())
}
#' Plot residual characteristics
@@ -217,6 +217,7 @@ arx <- function(x,order=c(1,1,1),lambda=0.1,intNoise=FALSE,
if(!fixedflag){
# checking for correct specification of fixed parameters
+ fixedA <- NULL;fixedB <- NULL
g(fixedA,fixedB) %=% lapply(fixed,length)
if(fixedA != na || fixedB != nb)
stop("Number of parameters incorrectly specified in 'fixed'")
@@ -597,7 +598,7 @@ bj <- function(z,order=c(1,1,1,1,0),
# Initial guess
theta0 <- matrix(params(init_sys))
- ivs <- matrix(predict(init_sys,x))
+ ivs <- matrix(predict(init_sys,z))
e_init <- y-ivs
} else{
nb <- order[1];nc <- order[2]; nd <- order[3];
diff --git a/R/idframe.R b/R/idframe.R
index c0fc2bf..3026d55 100644
--- a/R/idframe.R
+++ b/R/idframe.R
@@ -73,11 +73,11 @@ plot.idframe <- function(x,col="steelblue",lwd=1,main=NULL,size=12){
data <- cbind(outputData(x),inputData(x))
colnames(data) <- c(outputNames(x),inputNames(x))
}
- ggplot(melt(data.frame(time=as.numeric(time(data)), data), id.vars="time"),
- aes(time, value)) + geom_line(size=lwd,color=col) +
+ df <- melt(data.frame(time=as.numeric(time(data)), data), id.vars="time")
+ with(df,ggplot(df, aes(time, value)) + geom_line(size=lwd,color=col) +
facet_grid(variable ~ .,scales="free") + theme_bw(size) +
ylab("Amplitude") + ggtitle(main) +
- xlab(paste("Time (",x$unit,")",sep=""))
+ xlab(paste("Time (",x$unit,")",sep="")))
#theme(axis.title.x=element_text(size=11)) + ggtitle(main)
}
@@ -210,14 +210,14 @@ plot.idfrd <- function(x,col="steelblue",lwd=1){
melt_df <- reshape2::melt(df,id.var="Frequency")
yindex <- (i-1)%/%nin + 1;uindex <- i-nin*(yindex-1)
subtitle <- paste("From: u",uindex," to y",yindex,sep="")
- g[[i]] <- ggplot(melt_df, aes(Frequency, value)) +
+ g[[i]] <- with(melt_df,ggplot(melt_df, aes(Frequency, value)) +
geom_line(size=lwd,color=col) + scale_x_log10(expand = c(0.01,0.01)) +
facet_grid(variable ~ .,scales="free_y") +
theme_bw(14) + ylab("") + ggtitle(subtitle) +
xlab(ifelse(yindex==nout,"Frequency","")) +
theme(axis.title.x=element_text(color = "black",face = "plain"),
title=element_text(size=9,color = "black",face="bold")) +
- geom_vline(xintercept=max(x$freq),size=1)
+ geom_vline(xintercept=max(x$freq),size=1))
}
multiplot(plotlist=g,layout=matrix(1:length(g),nrow=nout,byrow=T))