Last chance! 50% off unlimited learning
Sale ends in
Functions that perform cross-validated parameter estimation and prediction for the spatio-temporal model.
# S3 method for STmodel
estimateCV(object, x, Ind.cv, control = list(trace = 3),
verbose.res = FALSE, ...)estimateCV(object, x, Ind.cv, ...)
# S3 method for STmodel
predictCV(object, x, Ind.cv = NULL, ..., silent = TRUE,
LTA = FALSE)
predictCV(object, x, Ind.cv, ...)
STmodel
object for which to perform cross-validation.
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
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
.
A list of control parameters for the optimisation.
See optim
for details; setting trace
=0
eliminates all ouput.
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
.
Show status after each iteration?
TRUE
/FALSE
, compute long-term temporal averages,
similar to computeLTA
, but with the option of including
the uncertainty; see predict.STmodel
.
Either a estCVSTmodel
object with elements:
Data.frame with convergence information and best function value for each cross-validation group.
The cross-validation grouping.
Fixed parameters in the estimation, see
estimate.STmodel
.
Matrix of inital values used, i.e. x
from the input.
Matrices with estimated parameters for each cross-validation group.
Standard deviations computed from the Hessian/information matrix for set of estimated parameters.
Estimation results for each cross-validation group,
contains the output from the estimate.STmodel
calls, only included if verbose.res=TRUE
.
Copy of the opts
field in the output from
predict.STmodel
.
The cross-validation grouping.
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
.
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
.
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.
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
# NOT RUN {
##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)
# }
# 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)
# }
# 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 )
# }
Run the code above in your browser using DataLab