View source: R/PLNfit-S3methods.R
predict_cond | R Documentation |
Predict counts of a new sample conditionally on a (set of) observed variables
predict_cond(
object,
newdata,
cond_responses,
type = c("link", "response"),
var_par = FALSE
)
## S3 method for class 'PLNfit'
predict_cond(
object,
newdata,
cond_responses,
type = c("link", "response"),
var_par = FALSE
)
object |
an R6 object with class |
newdata |
A data frame in which to look for variables and offsets with which to predict |
cond_responses |
a data frame containing the counts of the observed variables (matching the names provided as data in the PLN function) |
type |
The type of prediction required. The default is on the scale of the linear predictors (i.e. log average count) |
var_par |
Boolean. Should new estimations of the variational parameters of mean and variance be sent back, as attributes of the matrix of predictions. Default to |
A list containing:
pred |
A matrix of predicted log-counts (if |
M |
A matrix containing E(Z_uncond | Y_c) for each given site. |
S |
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)
#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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.