predict.comp_bayes_lm {forestecology}R Documentation

Make predictions based on fitted Bayesian model

Description

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

Usage

## S3 method for class '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.

Value

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

Source

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

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)

[Package forestecology version 0.2.0 Index]