comp_bayes_lm: Fit Bayesian competition model

Description Usage Arguments Value Source See Also Examples

View source: R/model_functions.R

Description

Fit a Bayesian linear regression model with interactions terms where

y = X β + ε

μ mean hyperparameter vector for β of length p + 1
V covariance hyperparameter matrix for β of dimension (p + 1) x (p + 1)
a shape hyperparameter for σ^2 > 0
b scale hyperparameter for σ^2 > 0

Usage

1
comp_bayes_lm(focal_vs_comp, prior_param = NULL, run_shuffle = FALSE)

Arguments

focal_vs_comp

data frame from create_focal_vs_comp()

prior_param

A list of {a_0, b_0, mu_0, V_0} prior hyperparameters. Defaults to a_0 = 250, b_0 = 250, mu_0 a vector of zeros of length p + 1, V_0 an identity matrix of dimension (p + 1) x (p + 1)

run_shuffle

boolean as to whether to run permutation test shuffle of competitor tree species within a particular focal_ID

Value

A list of {a_star, b_star, mu_star, V_star} posterior hyperparameters

Source

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

See Also

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

Examples

1
2
3
4
5
6
7
library(dplyr)

# Load in focal versus comp
data(focal_vs_comp_ex)

comp_bayes_lm_ex <- focal_vs_comp_ex %>%
  comp_bayes_lm(prior_param = NULL, run_shuffle = FALSE)

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