# use the landsat data
head(landsat)
# set up the model
model <- saemodel(formula = HACorn ~ PixelsCorn + PixelsSoybeans,
area = ~CountyName,
data = subset(landsat, subset = (outlier == FALSE)))
# summary of the model
summary(model)
# Huber M-estimate with robustness tuning constant k = 2
m <- fitsaemodel("huberm", model, k = 2)
m
# summary of the fitted model/ estimates
summary(m)
# robust prediction of the random effects and the area-level means (robust
# EBLUP) using the counts-specific means (landsat_means)
head(landsat_means)
# for robust prediction, we use the robustness tuning constant 'k = 1.8'
m_predicted <- robpredict(m, landsat_means, k = 1.8)
head(m_predicted)
# extract prediction as matrix
as.matrix(m_predicted)
# extract residuals from the predictions
head(residuals(m_predicted))
# prediction incl. MSPE; parametric bootstrap with only 'reps = 10'
# replications (for demonstration purposes; in practice, 'reps' should be
# considerably larger)
m_predicted_mspe <- robpredict(m, landsat_means, k = 1.8, reps = 10,
progress_bar = FALSE)
head(m_predicted_mspe)
Run the code above in your browser using DataLab