Predict counts of a new sample conditionally on a (set of) observed variables
an R6 object with class PLNfit
A data frame in which to look for variables and offsets with which to predict
a data frame containing the counts of the observed variables (matching the names provided as data in the PLN function)
The type of prediction required. The default is on the scale of the linear predictors (i.e. log average count)
Boolean. Should new estimations of the variational parameters of mean and variance be sent back, as attributes of the matrix of predictions. Default to FALSE
.
A list containing:
A matrix of predicted log-counts (if type = "link"
) or predicted counts (if type = "response"
)
A matrix containing E(Z_uncond | Y_c) for each given site.
A matrix containing Var(Z_uncond | Y_c) for each given site (sites are the third dimension of the array)
predict_cond(PLNfit)
: Predict counts of a new sample conditionally on a (set of) observed variables for a PLNfit
data(trichoptera)
trichoptera_prep <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
myPLN <- PLN(Abundance ~ Temperature + Wind, trichoptera_prep)
#>
#> Initialization...
#> Adjusting a full covariance PLN model with nlopt optimizer
#> Post-treatments...
#> DONE!
#Condition on the set of the first two species in the dataset (Hym, Hys) at the ten first sites
Yc <- trichoptera$Abundance[1:10, c(1, 2), drop=FALSE]
newX <- cbind(1, trichoptera$Covariate[1:10, c("Temperature", "Wind")])
pred <- predict_cond(myPLN, newX, Yc, type = "response")