Obtains predictions from a fitted joint trait distribution model and optionally computes their R squared and root mean square error (RMSE)
jtdm_predict(
m = m,
Xnew = NULL,
Ynew = NULL,
validation = FALSE,
FullPost = "mean"
)
A list containing:
Sample from the posterior distribution of the posterior predictive distribution. It is an array where the first dimension is the number of sites in Xnew, the second is the number of traits modelled and the third the number of MCMC samples. NULL if FullPost=FALSE.
Posterior mean of posterior predictive distribution
97.5% and 0.25% posterior quantiles of the posterior predictive distribution. NULL if FullPost=FALSE.
R squared of predictions (squared Pearson correlation between Ynew and the predictions). NULL if validation=FALSE.
Root square mean error between squared of predictions. NULL if validation=FALSE.
a model fitted with jtdm_fit
optionally, a data frame in which to look for variables with which to predict. If omitted, the fitted linear predictors are used
Optional. The observed response variables at sites specified in Xnew. It is used to compute goodness of fit metrics when validation= T.
boolean parameter to decide whether we want to compute goodness of fit measures. If true, then Ynew is needed.
The type of predictions to be obtain. If FullPost = TRUE, the function returns samples from the predictive distribution, the credible intervals are thus the predictive credible interval. If FullPost="mean", the function computes the posterior distribution of the regression term \(BXnew\)), i.e., classical credible intervals. If FullPost=FALSE, the function only returns the posterior mean of the regression term (\(BmeanXnew\)), i.e., no credible intervals.
To obtain a full assessment of the posterior distribution, the function should be ran with FullPost=TRUE, although this can be time consuming. FullPost="mean" is used to compute partial response curves, while FullPost=FALSE is used to compute goodness of fit metrics.
data(Y)
data(X)
m = jtdm_fit(Y = Y, X = X, formula=as.formula("~GDD+FDD+forest"), sample = 1000)
# marginal predictions of traits in the sites of X
pred = jtdm_predict(m)
Run the code above in your browser using DataLab