% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/benchmark.R
\name{cubicspline}
\alias{cubicspline}
\title{Benchmarking by means of Cubic Splines}
\usage{
cubicspline(
  s = NULL,
  t,
  nfreq = 4L,
  conversion = c("Sum", "Average", "Last", "First", "UserDefined"),
  obsposition = 1L
)
}
\arguments{
\item{s}{A preliminary series. If not \code{NULL}, it must be of the same class as \code{t}.}

\item{t}{The low-frequency aggregation constraint. It must be either an object of class \code{ts} or a numeric vector.}

\item{nfreq}{An integer giving the annual frequency of the benchmarked series.
This argument is used only when no preliminary series is provided.}

\item{conversion}{A character string specifying the conversion mode, typically \code{"Sum"} (the default) or \code{"Average"}. Other options are: \code{"Last"}, \code{"First"} and \code{"UserDefined"}.}

\item{obsposition}{An integer specifying the position of the observations of the low-frequency constraint within the benchmarked series (e.g. the 7th month of the year).
This argument is used only when \code{conversion = "UserDefined"}.}
}
\value{
A \code{"ts"} object with the benchmarked series is returned.
}
\description{
Cubic splines are piecewise cubic functions that are linked together in a way
to guarantee smoothness at data points. Additivity constraints are added for
benchmarking purpose and sub-period estimates are derived from each spline.
When a preliminary series is used, cubic splines are no longer drawn based on
the low-frequency constraint but the Benchmark-to-Indicator (BI ratio) is the
one being smoothed. Sub-period estimates are then simply the product between
the smoothed high frequency BI ratio and the preliminary series.
}
\examples{
\dontshow{if (rjd3toolkit::get_java_version() >= rjd3toolkit::minimal_java_version) withAutoprint(\{ # examplesIf}
data("qna_data")
Y <- ts(qna_data$B1G_Y_data[,"B1G_FF"], frequency = 1, start = c(2009,1))

# Cubic spline without preliminary series
y1 <- cubicspline(t = Y, nfreq = 4L)

# Cubic spline with preliminary series
x1 <- y1 + rnorm(n = length(y1), mean = 0, sd = 10)
cubicspline(s = x1, t = Y)

# Cubic splines used for temporal disaggregation
x2 <- ts(qna_data$TURN_Q_data[,"TURN_INDEX_FF"], frequency = 4, start = c(2009,1))
cubicspline(s = x2, t = Y)
\dontshow{\}) # examplesIf}
}
\seealso{
For more information, see the vignette:

\code{utils::browseVignettes()}, e.g. \code{browseVignettes(package = "rjd3bench")}
}
