Learn R Programming

far (version 0.6-7)

pred.persist: Forecasting using functional persistence

Description

Compute prediction of functional data using the persistence.

Usage

pred.persist(data, x, na.rm=TRUE, label, positive=FALSE)

Value

A fdata object.

Arguments

data

A fdata object.

x

A vector of character giving the names of the variables predicted.

na.rm

Logical. Does the n.a. need to be removed.

label

A vector of character giving the dates to associate to the predicted observations.

positive

Logical. Does the result must be forced to positive values.

Author

J. Damon

Details

The persistence model is a beautiful way to name the simplest model ever. This model just suppose that the next observation will be equal to the previous one, that is to say, noting \(\hat{X}_{n}\) the prediction for \(X_{n}\) that we "compute" :

$$\hat{X}_{n+1}=X_{n}$$

Of course, the intrinsic purpose of this model is to be a comparison for more complicated models.

The x option is provided to select the variable to predict, using the label option value as the labels for the new observations. Notices that the output as the same length as the input as it is only a shift in time.

In some special context, the user may need to suppress the na.rm observations with the na.rm option, or force the prediction to be positive with the positive option (in this case the maximum of 0 and the past value is computed).

See Also

predict.far,predict.kerfon.

Examples

Run this code
  # Simulation of a FARX process
  data1 <- simul.farx(m=10,n=40,base=base.simul.far(20,5),
                base.exo=base.simul.far(20,5),
                d.a=matrix(c(0.5,0),nrow=1,ncol=2),
                alpha.conj=matrix(c(0.2,0),nrow=1,ncol=2),
                d.rho=diag(c(0.45,0.90,0.34,0.45)),
                alpha=diag(c(0.5,0.23,0.018)),
                d.rho.exo=diag(c(0.45,0.90,0.34,0.45)),
                cst1=0.0)
  print(data2 <- pred.persist(data1,x="X",label="41"))
  print(unclass(select.fdata(data1,date=paste(38:40)))$X)
  print(unclass(select.fdata(data2,date=paste(39:41))))

Run the code above in your browser using DataLab