Applies fitted model from comp_bayes_lm() and returns posterior predicted values.

# S3 method for comp_bayes_lm
predict(object, newdata, ...)

Arguments

object

Output of comp_bayes_lm(): A list of {a_star, b_star, mu_star, V_star} posterior hyperparameters

newdata

A data frame of type focal_vs_comp in which to look for variables with which to predict.

...

Currently ignored—only included for consistency with generic.

Source

Closed-form solutions of Bayesian linear regression doi: 10.1371/journal.pone.0229930.s004

Value

A vector of predictions with length equal to the input data.

See also

Other modeling functions: comp_bayes_lm(), create_bayes_lm_data(), run_cv()

Examples

library(dplyr) library(sf) library(ggplot2) # Load in posterior parameter example # and growth data to compare to data(comp_bayes_lm_ex, growth_ex) predictions <- focal_vs_comp_ex %>% mutate(growth_hat = predict(comp_bayes_lm_ex, focal_vs_comp_ex)) predictions %>% ggplot(aes(growth, growth_hat)) + geom_point() + geom_abline(slope = 1, intercept = 0)