thetas_to_priors: Transforms hyperparameters to priors

View source: R/basic_functions.R

thetas_to_priorsR Documentation

Transforms hyperparameters to priors

Description

This function creates the priors on the variance and coefficients of the regressions from the three hyperparameters described in the mathematical description. The coefficients are assumed to have zero mean apriori, so only three prior elements are returned (the variance shape/scale, and the coefficnet variances).

Usage

thetas_to_priors(thetas, n, thresh = 0.001)

Arguments

thetas

3 real numbers representing the three hyperparameters; as it is on the log scale, it should generally be between -6 and 4 to avoid numerical issues (overflow or underflow)

n

the number of locations

thresh

the threshold for determining the number of neighbors based on the third hyperparameter, defaults to 1e-3

Value

List of priors, where

the first element is a vector of length n containing the shape parameters of the IG prior on the variances,

the second element similarly is of length n containing the corresponding scale parameters, and

the last element is an n * m matrix, where each row contains the prior variances for the regression coefficients (i.e. the diagonal of the prior covariance matrix)

Examples


thetas_ex <- c(1, 1, 1)
priors <- thetas_to_priors(thetas_ex, 100)

#with smaller threshold (leading to larger number of neighbors)
priors2 <- thetas_to_priors(thetas_ex, 500, thresh = 1e-6)


katzfuss-group/NPvecchia documentation built on April 15, 2022, 2:23 a.m.