Uses an object of class stratafit
from the stratafit()
function to predict the response on the unsampled sites for separate strata.
The column of the data set that has the response should have numeric values for the observed response
on the sampled sites and `NA` for any site that was not sampled.
Note that there is no newdata
argument to
predict.stratafit()
: any point in space for which a prediction
is needed should be included in the original data set in stratafit()
with the response variable as NA
.
# S3 method for stratafit
predict(object, wtscol = NULL, conf_level = 0.9, ...)
is an object generated from stratafit()
is the name of the column that contains the weights for prediction. The default setting predicts the population total
by default, 0.90, this is the desired confidence level for a prediction interval
further arguments passed to or from other methods.
a list with
the estimated population total
the estimated prediction variance
a data frame containing
x-coordinates
y-coordinates
density predictions
count predictions
site-by-site density prediction variances
site-by-site count prediction variances
indicator variable for whether or not the each site was sampled
estimated mean for each site
area of each site
vector with estimated covariance parameters
the formula used to fit the model in slmfit()
data(exampledataset) ## load a toy data set
exampledataset$strata <- c(rep("A", 19), rep("B", 21))
strataobj <- stratafit(formula = counts ~ pred1 + pred2,
data = exampledataset, stratacol = "strata",
xcoordcol = 'xcoords', ycoordcol = 'ycoords', areacol = 'areavar')
predict(strataobj)
#>
#> Prediction and Confidence Intervals:
#> Prediction SE 90% LB 90% UB
#> A 364.9 9.213 349.8 380.1
#> B 412.2 9.889 396.0 428.5
#> Total 777.1 13.515 754.9 799.4