View source: R/AuxiliaryFunctions_USER.R
predict.sclm | R Documentation |
It performs spatial prediction in a set of new S
spatial locations.
## S3 method for class 'sclm' predict(object, locPre, xPre, ...)
object |
object of class |
locPre |
matrix of coordinates for which prediction is performed. |
xPre |
matrix of covariates for which prediction is performed. |
... |
further arguments passed to or from other methods. |
This function predicts using the mean squared error (MSE) criterion, which takes the conditional expectation E(Y|X) as the best linear predictor.
The function returns a list with:
coord |
matrix of coordinates. |
predValues |
predicted values. |
sdPred |
predicted standard deviations. |
Katherine L. Valeriano, Alejandro OrdoƱez, Christian E. Galarza, and Larissa A. Matos.
EM.sclm
, MCEM.sclm
, SAEM.sclm
set.seed(1000) n = 120 coords = round(matrix(runif(2*n,0,15),n,2), 5) x = cbind(rbinom(n,1,0.50), rnorm(n), rnorm(n)) data = rCensSp(c(1,4,-1), 2, 3, 0.50, x, coords, "left", 0.10, 20) ## Estimation data1 = data$Data # Estimation: EM algorithm fit1 = EM.sclm(y=data1$y, x=data1$x, ci=data1$ci, lcl=data1$lcl, ucl=data1$ucl, coords=data1$coords, phi0=2.50, nugget0=1) # Estimation: SAEM algorithm fit2 = SAEM.sclm(y=data1$y, x=data1$x, ci=data1$ci, lcl=data1$lcl, ucl=data1$ucl, coords=data1$coords, phi0=2.50, nugget0=1) # Estimation: MCEM algorithm fit3 = MCEM.sclm(y=data1$y, x=data1$x, ci=data1$ci, lcl=data1$lcl, ucl=data1$ucl, coords=data1$coords, phi0=2.50, nugget0=1, MaxIter=300) cbind(fit1$theta, fit2$theta, fit3$theta) # Prediction data2 = data$TestData pred1 = predict(fit1, data2$coords, data2$x) pred2 = predict(fit2, data2$coords, data2$x) pred3 = predict(fit3, data2$coords, data2$x) # Cross-validation mean((data2$y - pred1$predValues)^2) mean((data2$y - pred2$predValues)^2) mean((data2$y - pred3$predValues)^2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.