comp_bayes_lm {forestecology}R Documentation

Fit Bayesian competition model

Description

Fit a Bayesian linear regression model with interactions terms where

y = X \beta + \epsilon

\mu mean hyperparameter vector for \beta of length p + 1
V covariance hyperparameter matrix for \beta of dimension (p + 1) x (p + 1)
a shape hyperparameter for \sigma^2 > 0
b scale hyperparameter for \sigma^2 > 0

Usage

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

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)

[Package forestecology version 0.2.0 Index]