Description Usage Arguments Details Value Author(s) See Also Examples
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.
1 | predictNaive(STmodel, locations = NULL, type = NULL)
|
STmodel |
|
locations |
Locations on which to base the naive predictions. |
type |
The type of sites to base the predictions on, uses the
(optional) field |
Given a set of locations the function computes 4 sets of naive prediction
for the observations in STmodel:
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.
The temporal average over sites in locations is
used as a naive prediction.
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.
This uses the observations at the closest site in
locations to predict observations at all other
sites.
A list with items:
pred |
A (number of observations) - by - (6) data.frame containing
the four naive predictions described under |
locations |
The locations used for the naive predictions. |
Johan Lindstrom
Other STmodel functions: createCV,
createDataMatrix,
createSTmodel,
dropObservations,
estimateBetaFields,
loglikeSTdim, loglikeST,
processLUR, processLocation,
updateCovf,
updateTrend.STdata
Other cross-validation functions: computeLTA,
createCV, dropObservations,
estimateCV.STmodel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ##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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.