predictNaive {SpatioTemporal} | R Documentation

## Naive Temporal Predictions

### Description

Computes naive predictions that are based on a few sites. These predictions can then be used, e.g. in `summary.predCVSTmodel`, to evaluate how much better the spatial-temporal model performs compared to simple (temporal) predictions.
The function requires one of `location` and `type` to be specified, if both are given `location` will be used over `type`. If `type` is given locations such that
`as.character(STmodel$locations$type) %in% type`
will be used.

### Usage

    predictNaive(STmodel, locations = NULL, type = NULL)

### Arguments

`STmodel` | `STmodel` object for which to compute simple predictions.
`locations` | Locations on which to base the naive predictions.
`type` | The type of sites to base the predictions on, uses the (optional) field `STmodel$locations$type`.

### Details

Given a set of locations the function computes 4 sets of naive prediction for the observations in `STmodel`:

smooth.fixed

  The smooth trend in `STmodel$trend` is fit to all observations at the sites in `locations` using a linear regression. The resulting smooth is used as a naive prediction for all locations.

avg.fixed

  The temporal average over sites in `locations` is used as a naive prediction.

smooth.closest.fixed

  This fits the smooth trend in `STmodel$trend` to each site in `locations`; using the smooth at the closest fixed site as a naive prediction.

closest.fixed

  This uses the observations at the closest site in `locations` to predict observations at all other sites.

### Value

A list with items:

`pred` | A (number of observations) - by - (6) data.frame containing the four naive predictions described under `details`, along with dates and IDs.
`locations` | The locations used for the naive predictions.

### Author(s)

Johan Lindstrom

### See Also

Other STmodel functions: `createCV`, `createDataMatrix`, `createSTmodel`, `dropObservations`, `estimateBetaFields`, `loglikeSTdim`, `loglikeST`, `processLUR`, `processLocation`, `updateCovf`, `updateTrend.STdata`

Other cross-validation functions: `computeLTA`, `createCV`, `dropObservations`, `estimateCV.STmodel`

### Examples

    ##load data
    data(mesa.model)

    ##naive predictions based on either AQS,
    pred.aqs <- predictNaive(mesa.model, type="AQS")
    ##...or only one sites,
    pred.1site <- predictNaive(mesa.model, locations="60372005")

    ##plot the predictions - The two cases that are constant in space
    par(mfcol=c(2,1), mar=c(4.5,4.5,1,.5))

    ##observations as a function of date
    plot(mesa.model, "loc.obs", type=as.factor(mesa.model$locations$ID),
         legend.loc=NULL, pch=19, cex=.25)
    ##Add the predictions based on the smooth fitted to all sites
    with(pred.aqs$pred, lines(date, smooth.fixed, col=1, lwd=2) )
    with(pred.1site$pred, lines(date, smooth.fixed, col=2, lwd=2) )

    ##plot the predictions - One of the cases that vary in space, i.e. the smooth
    ##fit to the closest site.
    ##first extract as a data matrix
    D <- with(pred.aqs$pred, createDataMatrix(obs=smooth.closest.fixed,
                                              date=date, ID=ID) )

    ##observations as a function of date
    ##(only five sites for clarity)
    mesa.model <- dropObservations(mesa.model, !(mesa.model$obs$idx %in% c(1,2,3,23,24)))
    plot(mesa.model, "loc.obs", type=as.factor(mesa.model$locations$ID),
         legend.loc=NULL, pch=19, cex=.25)
    ##Add the predictions based on the smooth
    ##fitted to the closest site
    for(i in 1:5){
      lines(as.Date(rownames(D)), D[,mesa.model$locations$ID[i]], col=i, lwd=2)
    }

[Package SpatioTemporal version 1.1.9.1 Index]