Example for new location prediction, Gaussian process method, and our COST method with Gaussian and t copulas, where the parameters are assumed to be known; the parameters can be obtained by the ``optim" function. Data are generated at 13 locations and n time points, and assume that 9 locations are observed, and 4 new locations need prediction at time n, conditional on 9 locations at time points n-1 and n.
example.prediction(n,n.total,seed1)
Arguments
n: number of time points for parameter estimation
n.total: number of total time points, with a burning sequence
seed1: random seed to generate a data set, for reproducibility
Returns
COST.t.pre.ECP: a vector of length K=4 (number of new locations), with value 1 or 0, 1 means the verifying value from the corresponding location lies in the 95% prediction interval, 0 means not
COST.t.pre.ML: a vector of length K=4, each element is the length of prediction interval of the corresponding location
COST.t.pre.med.error: prediction error based on conditional median
COST.G.pre.ECP: same as COST.t.pre.ECP
COST.G.pre.ML: same as COST.t.pre.ML
COST.G.pre.med.error: same as COST.t.pre.med.error
library(COST)#settingsn.total =101#number of total time points, including the burning sequencen =50#number of time points we observedseed1 =22222example.prediction(n,n.total,seed1)#OUTPUTS# $COST.t.pre.ECP #whether the prediction interval includes the true value, time point n# [1] 1 1 1 1## $COST.t.pre.ML #length of the prediction interval# [1] 1.445576 2.146452 2.260688 2.706681## $COST.t.pre.med.error #point prediction error, using conditional median# [1] 0.01127162 -0.03222058 -0.22081051 0.57831480## $COST.G.pre.ECP #whether the prediction interval includes the true value, time point n# [1] 1 1 1 1## $COST.G.pre.ML #length of the prediction interval# [1] 1.445576 2.432646 2.260688 2.914887## $COST.G.pre.med.error #point prediction error, using conditional median# [1] 0.01127162 -0.03222058 -0.22081051 0.57831480## $GP.pre.ECP #whether the prediction interval includes the true value, time point n# [1] 1 1 1 1## $GP.pre.ML #length of the prediction interval# [1] 0.8345359 1.4096642 1.5948724 2.3419428## $GP.pre.med.error #point prediction error, using conditional median# [1] 0.09447685 -0.05889409 -0.08923935 0.58494684