summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-04-01 03:23:35 +0530
committerSuraj Yerramilli2015-04-01 03:23:35 +0530
commit058d47522706582c3c2a80579cbe39075d3cee28 (patch)
treef040e5be5349dc804cb9e5a6484726a5c109f331
parenta263a53deec7e3a0909b20207cf5629bd39a92c6 (diff)
downloadSysID-R-code-058d47522706582c3c2a80579cbe39075d3cee28.tar.gz
SysID-R-code-058d47522706582c3c2a80579cbe39075d3cee28.tar.bz2
SysID-R-code-058d47522706582c3c2a80579cbe39075d3cee28.zip
cleaning code
-rw-r--r--R/idframe.R7
-rw-r--r--R/impute.R53
-rw-r--r--R/readData.R8
-rw-r--r--man/dataImpute.Rd37
-rw-r--r--man/dataPartition.Rd27
-rw-r--r--man/predict.demean.Rd31
-rw-r--r--man/predict.detrend.idframe.Rd31
-rw-r--r--man/print.tf.Rd15
8 files changed, 12 insertions, 197 deletions
diff --git a/R/idframe.R b/R/idframe.R
index 22c663d..e173961 100644
--- a/R/idframe.R
+++ b/R/idframe.R
@@ -13,6 +13,10 @@
#' recorded (Valid only if type="frequency")
#' @param fUnit Frequency Unit (Valid only if type="frequency")
#' @return an idframe object
+#'
+#' @examples
+#'
+#'
#' @export
idframe <- function(output=numeric(0),input=numeric(0),
type=c("time","freq")[1],Ts = 1,
@@ -91,7 +95,6 @@ plot.idframe <- function(object,...){
}
}
-#' @export
index <- function(object){
if(object$type=="time"){
return(seq(from=object$t.start,to=object$t.end,by=object$Ts))
@@ -122,7 +125,7 @@ summary.idframe <- function(object){
return(out)
}
-#' @export
+
print.summary.idframe <- function(object,...){
cat("Domain: ");cat(object$type)
cat("\t\t Number of samples:");cat(object$no_of_samples)
diff --git a/R/impute.R b/R/impute.R
deleted file mode 100644
index a9db126..0000000
--- a/R/impute.R
+++ /dev/null
@@ -1,53 +0,0 @@
-#' Impute missing values
-#'
-#' Uses the bootstrap EM Algorithm on incomplete data and creates imputed datasets
-#'
-#' @param data an object of class \code{idframe}
-#' @param m the number of imputed datasets to create.
-#'
-#' @return
-#' A list containing the following elements
-#'
-#' \tabular{ll}{
-#' \code{imputations} \tab a list of length \code{m} with an imputed dataset in each
-#' entry. Each element is of class \code{idframe} \cr
-#' \code{m} \tab an integer indicating the number of imputations run
-#' }
-#'
-#' @details
-#' This function uses the \code{\link[Amelia]{amelia}} function, provided by the
-#' \pkg{amelia} package, to perform multiple imputation.
-#'
-#' @references
-#' Honaker, J., King, G., Blackwell, M. (2011). Amelia II: A Program for Missing Data.
-#' Journal of Statistical Software, 45(7), 1–47. URL http://www.jstatsoft.org/v45/i07/.
-#'
-#' @seealso \code{\link[Amelia]{amelia}}
-#' @export
-dataImpute <- function(data,m=1){
- # check if the class is correct
- if(class(data)!='idframe')
- stop("Not an idframe data")
-
- dataMatrix <- cbind(data$input,data$output)
-
- a.out <- amelia(dataMatrix,m=m,p2s = 0)
-
- a.assign <- function(dataMatrix,data){
- ninputs <- dim(data$input)[2]
- out <- data
-
- colIndex <- 1:(dim(dataMatrix)[2])
- inputIndex <- 1:ninputs
- outputIndex <- colIndex[!(colIndex %in% inputIndex)]
-
- out$input <- dataMatrix[,1:inputIndex,drop=F]
- out$output <- dataMatrix[,1:outputIndex,drop=F]
-
- return(out)
- }
-
- imputations <- lapply(X=a.out$imputations,FUN=a.assign,data=data)
-
- return(list(imputations=imputations,m=m))
-} \ No newline at end of file
diff --git a/R/readData.R b/R/readData.R
index 971b422..16515ea 100644
--- a/R/readData.R
+++ b/R/readData.R
@@ -17,9 +17,12 @@
#' should contain the frequencies.
#'
#' @return an idframe object
+#' @examples
+#' dat <- read.idframe(data,freqData = FALSE, ninputs=2,type="time",
+#' Ts = 1,tUnit="min")
#' @export
read.idframe <- function(data,freqData=FALSE,ninputs=1,
- type=c("time","freq")[1],Ts = 1,tUnit="time"){
+ type=c("time","freq")[1],Ts = 1,tUnit="sec"){
if((type=="freq") && (freqData)){
@@ -71,6 +74,9 @@ read.idframe <- function(data,freqData=FALSE,ninputs=1,
#' should contain the frequencies.
#'
#' @return an idframe object
+#' @examples
+#'
+#'
#' @export
#' @seealso \code{\link[utils]{read.table}}
read.table.idframe <- function(file,header=TRUE,sep=",",ninputs=1,
diff --git a/man/dataImpute.Rd b/man/dataImpute.Rd
deleted file mode 100644
index eb0763b..0000000
--- a/man/dataImpute.Rd
+++ /dev/null
@@ -1,37 +0,0 @@
-% Generated by roxygen2 (4.1.0): do not edit by hand
-% Please edit documentation in R/impute.R
-\name{dataImpute}
-\alias{dataImpute}
-\title{Impute missing values}
-\usage{
-dataImpute(data, m = 1)
-}
-\arguments{
-\item{data}{an object of class \code{idframe}}
-
-\item{m}{the number of imputed datasets to create.}
-}
-\value{
-A list containing the following elements
-
-\tabular{ll}{
- \code{imputations} \tab a list of length \code{m} with an imputed dataset in each
- entry. Each element is of class \code{idframe} \cr
- \code{m} \tab an integer indicating the number of imputations run
- }
-}
-\description{
-Uses the bootstrap EM Algorithm on incomplete data and creates imputed datasets
-}
-\details{
-This function uses the \code{\link[Amelia]{amelia}} function, provided by the
-\pkg{amelia} package, to perform multiple imputation.
-}
-\references{
-Honaker, J., King, G., Blackwell, M. (2011). Amelia II: A Program for Missing Data.
-Journal of Statistical Software, 45(7), 1–47. URL http://www.jstatsoft.org/v45/i07/.
-}
-\seealso{
-\code{\link[Amelia]{amelia}}
-}
-
diff --git a/man/dataPartition.Rd b/man/dataPartition.Rd
deleted file mode 100644
index 2ac7ef5..0000000
--- a/man/dataPartition.Rd
+++ /dev/null
@@ -1,27 +0,0 @@
-% Generated by roxygen2 (4.1.0): do not edit by hand
-% Please edit documentation in R/partition.R
-\name{dataPartition}
-\alias{dataPartition}
-\title{Split data into training and validation sets}
-\usage{
-dataPartition(data, p = 0.6)
-}
-\arguments{
-\item{data}{an object of class \code{idframe}}
-
-\item{p}{the percentage of the data that goes to training (Default : \code{0.6})}
-}
-\value{
-list containing estimation and validation idframe datas
-}
-\description{
-The function splits the data into training and validation sets and returns them bundled
-as a list. The size of the sets are determined by the parameter \code{p}.
-}
-\examples{
-data(cstr)
-splitList <- dataPartition(cstr,p=0.6)
-train <- splitList$estimation # training set
-test <- splitList$validation # testing set
-}
-
diff --git a/man/predict.demean.Rd b/man/predict.demean.Rd
deleted file mode 100644
index 9abea86..0000000
--- a/man/predict.demean.Rd
+++ /dev/null
@@ -1,31 +0,0 @@
-% Generated by roxygen2 (4.1.0): do not edit by hand
-% Please edit documentation in R/demean.R
-\name{predict.demean}
-\alias{predict.demean}
-\title{Predict the centered values}
-\usage{
-\method{predict}{demean}(object, newdata = NULL, ...)
-}
-\arguments{
-\item{object}{an object of class \code{idframe}}
-
-\item{newdata}{An optional idframe object in which to look for variables with which
-to predict. If ommited, the original idframe object is used}
-}
-\value{
-an \code{idframe} object
-}
-\description{
-Center an \code{idframe} object based on the training center means
-}
-\examples{
-## Examples for train and test sets
-data(cstr)
-splitList <- dataPartition(cstr,p=0.6)
-train <- splitList$estimation # training set
-test <- splitList$validation # testing set
-fit.mean <- demean(train)
-train_demean <- predict(fit.mean)
-test_demean <- predict(fit.mean,newdata=test)
-}
-
diff --git a/man/predict.detrend.idframe.Rd b/man/predict.detrend.idframe.Rd
deleted file mode 100644
index 938cd31..0000000
--- a/man/predict.detrend.idframe.Rd
+++ /dev/null
@@ -1,31 +0,0 @@
-% Generated by roxygen2 (4.1.0): do not edit by hand
-% Please edit documentation in R/detrend.R
-\name{predict.detrend.idframe}
-\alias{predict.detrend.idframe}
-\title{Predict method for trend fits on idframe objects}
-\usage{
-\method{predict}{detrend.idframe}(object, newdata = NULL, ...)
-}
-\arguments{
-\item{object}{an object of class \code{idframe}}
-
-\item{newdata}{An optional idframe object in which to look for variables with which
-to predict. If ommited, the original detrended idframe object is used}
-}
-\value{
-an \code{idframe} object
-}
-\description{
-Detrended \code{idframe} object based on linear trend fit
-}
-\examples{
-## Examples for train and test sets
-data(cstr)
-splitList <- dataPartition(cstr,p=0.6)
-train <- splitList$estimation # training set
-test <- splitList$validation # testing set
-fit <- detrend.idframe(train)
-train_detrend <- predict(fit)
-test_detrend <- predict(fit,newdata=test)
-}
-
diff --git a/man/print.tf.Rd b/man/print.tf.Rd
deleted file mode 100644
index cc0ea03..0000000
--- a/man/print.tf.Rd
+++ /dev/null
@@ -1,15 +0,0 @@
-% Generated by roxygen2 (4.1.0): do not edit by hand
-% Please edit documentation in R/tf.R
-\name{print.tf}
-\alias{print.tf}
-\title{Display the Transfer Function}
-\usage{
-\method{print}{tf}(G)
-}
-\arguments{
-\item{G}{an object of class \code{tf}}
-}
-\description{
-Printing method for objects inheriting from class \code{tf}
-}
-