estimateCV.STmodel {SpatioTemporal} | R Documentation

## Cross-Validated Estimation and Prediction

### Description

Functions that perform cross-validated parameter estimation and prediction for the spatio-temporal model.

### Usage

    ## S3 method for class 'STmodel'
    estimateCV(object, x, Ind.cv, control = list(trace = 3),
      verbose.res = FALSE, ...)

    estimateCV(object, x, Ind.cv, ...)

    ## S3 method for class 'STmodel'
    predictCV(object, x, Ind.cv = NULL, ..., silent = TRUE,
      LTA = FALSE)

    predictCV(object, x, Ind.cv, ...)

### Arguments

`object` | `STmodel` object for which to perform cross-validation.
`x` | Either a vector or matrix of starting point(s) for the optimisation, see `estimate.STmodel`; or a matrix with parameters, the i:th row being used for prediction of the i:th cross-validation set. For prediction either a `estCVSTmodel` or `estimateSTmodel` object, results from `estimateCV.STmodel` or `estimate.STmodel`, can be used.
`Ind.cv` | `Ind.cv` defines the cross-validation scheme. Either a (number or observations) - by - (groups) logical matrix or an integer valued vector with length equal to (number or observations). For `predictCV.STmodel` `Ind.cv` can be infered from `x` if `x` is a `estCVSTmodel` object See further `createCV`.
`control` | A list of control parameters for the optimisation. See `optim` for details; setting `trace`=0 eliminates all ouput.
`verbose.res` | A `TRUE`/`FALSE` variable indicating if full results from `estimate.STmodel` for each CV group should be returned; defaults to `FALSE`
`...` | All additional parameters for `estimate.STmodel` or `predict.STmodel`. For `predict.STmodel` a number of parameters are set in `predictCV.STmodel` and can NOT be overriden, these are `nugget.unobs`, `only.pars=FALSE`, and `combine.data=FALSE`.
`silent` | Show status after each iteration?
`LTA` | `TRUE`/`FALSE`, compute long-term temporal averages, similar to `computeLTA`, but with the option of including the uncertainty; see `predict.STmodel`.

### Details

For `predictCV.STmodel` the parameters used to compute predictions for the left out observations can be either a single vector or a matrix. For a single vector the same parameter values will be used for all cross-validation predictions; for a matrix the parameters in `x[,i]` will be used for the predictions of the i:th cross-validation set (i.e. for `Ind.cv[,i]`). Suitable matrices are provided in the output from `estimateCV.STmodel`.

The cross-validation groups are given by `Ind.cv`. `Ind.cv` should be either a (number of observations) - by - (groups) logical matrix or an integer valued vector with length equal to (number of observations). If a matrix then each column defines a cross-validation set with the `TRUE` values marking the observations to be left out. If a vector then `1`:s denote observations to be dropped in the first cross-validation set, `2`:s observations to be dropped in the second set, etc. Observations marked by values `<=0` are never dropped. See `createCV` for details.

### Value

Either a `estCVSTmodel` object with elements:

`status` | Data.frame with convergence information and best function value for each cross-validation group.
`Ind.cv` | The cross-validation grouping.
`x.fixed` | Fixed parameters in the estimation, see `estimate.STmodel`.
`x.init` | Matrix of inital values used, i.e. `x` from the input.
`par.all, par.cov` | Matrices with estimated parameters for each cross-validation group.
`par.all.sd, par.cov.sd` | Standard deviations computed from the Hessian/information matrix for set of estimated parameters.
`res.all` | Estimation results for each cross-validation group, contains the output from the `estimate.STmodel` calls, only included if `verbose.res=TRUE`.

Or a `predCVSTmodel` object with elements:

`opts` | Copy of the `opts` field in the output from `predict.STmodel`.
`Ind.cv` | The cross-validation grouping.
`pred.obs` | A data.frame with a copy of observations from `object$obs`, predictions (for different model components), variances, and residuals. Variance field will be missing if `pred.var=FALSE`.
`pred.all` | A list with time-by-location data.frames containing predictions and variances for all space-time locations as well as predictions and variances for the beta-fields. Unobserved points are `NA` for the option `only.obs=TRUE`.

### Author(s)

Johan Lindstrom

### See Also

Other STmodel methods: `MCMC.STmodel`, `c.STmodel`, `createSTmodel`, `estimate.STmodel`, `plot.STdata`, `predict.STmodel`, `print.STmodel`, `print.summary.STmodel`, `qqnorm.predCVSTmodel`, `scatterPlot.predCVSTmodel`, `simulate.STmodel`, `summary.STmodel`

Other cross-validation functions: `computeLTA`, `createCV`, `dropObservations`, `predictNaive`

Other estCVSTmodel methods: `boxplot.estCVSTmodel`, `coef.estCVSTmodel`, `print.estCVSTmodel`, `print.summary.estCVSTmodel`, `summary.estCVSTmodel`

Other predCVSTmodel functions: `computeLTA`

Other predCVSTmodel methods: `plot.predCVSTmodel`, `print.predCVSTmodel`, `print.summary.predCVSTmodel`, `qqnorm.predCVSTmodel`, `scatterPlot.predCVSTmodel`, `summary.predCVSTmodel`

### Examples

    ##load data
    data(mesa.model)
    data(est.mesa.model)

    ################
    ## estimateCV ##
    ################
    ##create the CV structure defining 10 different CV-groups
    Ind.cv <- createCV(mesa.model, groups=10, min.dist=.1)

    ##use the best parameters and there starting values as
    x.init <- coef(est.mesa.model, pars="cov")[,c("par","init")]

    ## Not run:
      ##estimate different parameters for each CV-group
      est.cv.mesa <- estimateCV(mesa.model, x.init, Ind.cv)

    ## End(Not run)
    ##lets load precomputed results instead
    data(est.cv.mesa)

    ##examine the estimation results
    print( est.cv.mesa )
    ##estimated parameters for each CV-group
    coef(est.cv.mesa, pars="cov")

    ###############
    ## predictCV ##
    ###############
    ## Not run:
      ##Do cross-validated predictions using the just estimated parameters
      ##Ind.cv is infered from est.cv.mesa as est.cv.mesa$Ind.cv
      pred.cv.mesa <- predictCV(mesa.model, est.cv.mesa, LTA=TRUE)

    ## End(Not run)
    ##lets load precomputed results instead
    data(pred.cv.mesa)

    ##prediction results
    print( pred.cv.mesa )

    ##and CV-statistics
    print( summary( pred.cv.mesa, LTA=TRUE) )

    ## Not run:
      ##A faster option is to only consider the observations and not to compute
      ##variances
      pred.cv.fast <- predictCV(mesa.model, est.cv.mesa, only.obs=TRUE,
                                pred.var=FALSE)
      print( pred.cv.fast )
      summary( pred.cv.fast )

    ## End(Not run)

[Package SpatioTemporal version 1.1.9.1 Index]