predict.sclm: Prediction in Spatial Model with censored/missing responses

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/AuxiliaryFunctions_USER.R

Description

This function performs spatial prediction in a set of new S spatial locations.

Usage

1
2
## S3 method for class 'sclm'
predict(object, locPre, xPre, ...)

Arguments

object

object of class 'sclm' given as output of EM.sclm, SAEM.sclm or MCEM.sclm function.

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.

Details

This function predicts using the Mean Squared Error (MSE) criterion, which takes the conditional expectation E(Y|X) as the best linear predictor.

Value

The function returns a data frame with:

xcoord

x coordinates.

ycoord

y coordinates.

predValues

predicted values.

sdPred

predicted standard deviations.

Author(s)

Katherine L. Valeriano, Alejandro Ordonez, Christian E. Galarza and Larissa A. Matos.

See Also

EM.sclm, SAEM.sclm, MCEM.sclm

Examples

 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
n = 120
set.seed(1000)
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,"exponential",0)

# Estimation
data1 = data$TrainingData
# EM algorithm
fit1 = EM.sclm(y=data1$yobs, x=data1[,7:9], cens=data1$cens,LI=data1$LI,
             LS=data1$LS, coords=data1[,5:6], init.phi=2.50, init.nugget=1,
             type="exponential", show.SE=TRUE, error=1e-4)
# SAEM algorithm
fit2 = SAEM.sclm(y=data1$yobs,x=data1[,7:9],cens=data1$cens,LI=data1$LI,
             LS=data1$LS, coords=data1[,5:6], init.phi=2.50, init.nugget=1,
             type="exponential", show.SE=TRUE, error=1e-4)
# MCEM algorithm
fit3 = MCEM.sclm(y=data1$yobs,x=data1[,7:9],cens=data1$cens,LI=data1$LI,
             LS=data1$LS, coords=data1[,5:6], init.phi=2.50, init.nugget=1,
             type="exponential", MaxIter=300, show.SE=TRUE, error=1e-4)
c(fit1$theta)
c(fit2$theta)
c(fit3$theta)

# Prediction
data2 = data$TestData
pred1 = predict(fit1, data2[,2:3], data2[,4:6])
pred2 = predict(fit2, data2[,2:3], data2[,4:6])
pred3 = predict(fit3, data2[,2:3], data2[,4:6])

# Cross-validation
mean((data2$yobs - pred1$predValues)^2)
mean((data2$yobs - pred2$predValues)^2)
mean((data2$yobs - pred3$predValues)^2)

RcppCensSpatial documentation built on Sept. 21, 2021, 5:07 p.m.