MINI MINI MANI MO

Path : /opt/oracle/product/18c/dbhomeXE/R/library/OREeda/doc/man/en/
File Upload :
Current File : //opt/oracle/product/18c/dbhomeXE/R/library/OREeda/doc/man/en/ore.esm.Rd

%
% Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
%
\name{ore.esm}
\alias{ore.esm}
\alias{fitted.ore.esm}
\alias{forecast.ore.esm}
\alias{predict.ore.esm}
\alias{fitted}
\alias{predict}

\title{Oracle R Enterprise Time Series Exponential Smoothing Models}
\description{Creates exponential smoothing models on ordered
  \code{ore.vector} data.}
\usage{

ore.esm(x,
        interval = NULL,
        model = "simple",
        accumulate = "NONE",
        setmissing = "PREV",
        optim.start = c(alpha=0.3, beta=0.1),
        optim.control = list())

\S3method{fitted}{ore.esm}(object, start = NULL, end = NULL, ...)
\S3method{predict}{ore.esm}(object, n.ahead = 12L,  ...)

forecast.ore.esm(object, h = 12L, ...)
}

\arguments{
  \item{x}{ An ordered \code{ore.vector} of time series data or
    transactional data. The ordering column could be either integers
    from 1 to the length of the time series or of type \code{ore.datetime}.}
  \item{interval}{ The interval of the time series, or the time
    interval by which the transactional data is to be accumulated. If
    the ordering column of the argument \code{x} is of type
    \code{ore.datetime}, \code{interval} must be specified.

    Possible values: \code{"YEAR"}, \code{"QTR"}, \code{"MONTH"},
    \code{"WEEK"}, \code{"DAY"}, \code{"HOUR"}, \code{"MINUTE"},
    \code{"SECOND"} }

  \item{model}{ The exponential smoothing model name. Possible values: \code{"simple"}, \code{"double"} }
  \item{accumulate}{ The method of accumulation.

    Possible values:
  \tabular{ll}{
  \code{"NONE"         } \tab No accumulation occurs. In this case,
  the argument \code{x} is required to be equally spaced time series
  observations.\cr
  \code{"TOTAL"        } \tab Accumulation based on the sum of the observed values. \cr
  \code{"AVERAGE"      } \tab Accumulation based on the average of the
  observed values. The value could be abbreviated to \code{"AVG"}. \cr
  \code{"MINIMUM"      } \tab Accumulation based on the minimum of the
  observed values. The value could be abbreviated to \code{"MIN"}. \cr
  \code{"MAXIMUM"      } \tab Accumulation based on the maximum of the
  observed values. The value could be abbreviated to \code{"MAX"}. \cr
  \code{"MEDIAN"       } \tab Accumulation based on the median of the
  observed values. The value could be abbreviated to \code{"MED"}. \cr
  \code{"STDDEV"       } \tab Accumulation based on the standard
  deviation of the observed values. The value could be abbreviated
  to \code{"STD"}. \cr
  \code{"N"            } \tab Accumulation based on the number of nonmissing observations. \cr
  \code{"NOBS"         } \tab Accumulation based on the number of observations. \cr
  \code{"NMISS"        } \tab Accumulation based on the number of missing observations.
}
}
  \item{setmissing}{ The method of treating missing values.

    Possible values:
  \tabular{ll}{
  \code{"AVERAGE"       } \tab Missing values are set to the average of the
  accumulated values. The value could be abbreviated to \code{"AVG"}. \cr
  \code{"MINIMUM"       } \tab Missing values are set to the minimum of the
  accumulated values. The value could be abbreviated to \code{"MIN"}. \cr
  \code{"MAXIMUM"       } \tab Missing values are set to the maximum of the
  accumulated values. The value could be abbreviated to \code{"MAX"}. \cr
  \code{"MEDIAN"        } \tab Missing values are set to the median of the
  accumulated values. The value could be abbreviated to \code{"MED"}. \cr
  \code{"FIRST"         } \tab Missing values are set to the first accumulated nonmissing value. \cr
  \code{"LAST"          } \tab Missing values are set to the last accumulated nonmissing value. \cr
  \code{"PREVIOUS"      } \tab Missing values are set to the previous
  accumulated nonmissing value. The value could be abbreviated to
  \code{"PREV"}. \cr
  \code{"NEXT"          } \tab Missing values are set to the next accmulated nonmissing value.
}}
  \item{optim.start}{ A vector with named components \code{alpha} and
    \code{beta} containing the starting values for the
    optimizer. The starting values should be in the range of 0 to
    1. Ignored in the \code{simple} model case.} 
  \item{optim.control}{ Optional list with additional control parameters
  passed to \code{optim} in the \code{double} model case. Ignored in the
\code{simple} model case.}
  \item{object}{ An object of type \code{ore.esm}. }
  \item{start}{A positive integer that specifies the beginning index of the
    output of the fitted values. If a value is specified, it should be
    less than or equal to the argument \code{end}. The default is
    \code{NULL}, which indicates \code{start=1}. }
  \item{end}{A positive integer that specifies the ending index of the
    output of the fitted values. If a value is specified, it should be
    greater than or equal to the argument \code{start}.
    The default is \code{NULL}, which indicates the value is equal to
    the length of the training dataset.}
  \item{n.ahead}{ The number of time periods to forecast. }
  \item{h}{ The number of time periods to forecast. }
  \item{...}{ Additional arguments. }
}

\value{
    For \code{ore.esm}, returns an object of class \code{"ore.esm"}. Some of its components are as follows:
    \item{smoothing.param}{ The estimated smoothing parameters. }
    \item{model}{ The model type. }
    \item{model.param }{ The input arguments. }

    For \code{fitted.ore.esm}, returns an \code{ore.vector} of fitted
    values of the model in the range that is specified by the arguments
    \code{start} and \code{end}.

    For \code{predict.ore.esm} or \code{forecast.ore.esm}, returns a
    \code{data.frame} of the predicted time series.
}

\details{
The function \code{ore.esm} implements exponential smoothing models for
in-database time series observations. The function can work with either
time series data, whose observations are evenly spaced by a fixed
interval, or transactional data, whose observations are not equally
spaced. For transactional data, specify an aggregation method with the argument
\code{accumulate} and a time interval with the argument \code{interval}. To
handle missing values, specify a value with the argument \code{setmissing}. The
function preprocesses the data using the specified aggregation method, time
intervals, and handling of missing values.

The \code{fitted} method provides the fitted times series values aligned
with the training dataset. The arguments \code{start} and \code{end}
specify the index range of the output fitted values. This function
currently does not support a model built with an accumulation method specified.

The \code{predict} method predicts the time series by using the exponential
smoothing model built by \code{ore.esm}. If the \code{forecast} package
is loaded, the \code{forecast} method can be called through generic.
}

\references{
  Exponential Smoothing method
   \url{http://en.wikipedia.org/wiki/Exponential_smoothing}

  \href{http://www.oracle.com/technetwork/database/database-technologies/r/r-enterprise/documentation/index.html}{Oracle R Enterprise}
}
      
\author{
  Oracle \email{oracle-r-enterprise@oracle.com}
}

\examples{
  # case 1
  N <- 5000
  ts0 <- ore.push(data.frame(ID=1:N,
    VAL=seq(1,5,length.out=N)^2+rnorm(N,sd=0.5)))
  rownames(ts0) <- ts0$ID
  x <- ts0$VAL

  esm.mod <- ore.esm(x, model = "double")
  esm.predict <- predict(esm.mod, 30)
  esm.fitted <- fitted(esm.mod, start=4000, end=5000)
  plot(ts0[4000:5000,], pch='.')
  lines(ts0[4000:5000, 1], esm.fitted, col="blue")
  lines(esm.predict, col="red", lwd=2)

  #case 2
  ts01 <- data.frame(ID=seq(as.POSIXct("2008/6/13"), as.POSIXct("2011/6/16"),
                     length.out=4000), VAL=rnorm(4000, 10))
  ts02 <- data.frame(ID=seq(as.POSIXct("2011/7/19"), as.POSIXct("2012/11/20"),
                     length.out=1500), VAL=rnorm(1500, 10))
  ts03 <- data.frame(ID=seq(as.POSIXct("2012/12/09"), as.POSIXct("2013/9/25"),
                     length.out=1000), VAL=rnorm(1000, 10))
  ts1 = ore.push(rbind(ts01, ts02, ts03))
  rownames(ts1) <- ts1$ID
  x <- ts1$VAL
  esm.mod <- ore.esm(x, "DAY", accumulate = "AVG", model="simple",
                     setmissing="PREV")
  esm.predict <- predict(esm.mod)

  #case 3
  x <- ore.push(BJsales)

  esm.mod <- ore.esm(x, model="double")
  esm.predict <- predict(esm.mod)
  esm.fitted <- fitted(esm.mod)

  library(OREgraphics)
  plot(x)
  lines(esm.fitted, col="blue")
  lines(esm.predict, col="red", lwd=4)
}


OHA YOOOO