predict.comp_bayes_lm: Make predictions based on fitted Bayesian model

Description Usage Arguments Value Source See Also Examples

Description

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

Usage

1
2
## 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)

forestecology documentation built on Oct. 2, 2021, 5:07 p.m.