sdPrior (version 1.0-0)

get_theta_ig: Find Scale Parameter for Inverse Gamma Hyperprior

Description

This function implements a optimisation routine that computes the scale parameter b of the inverse gamma prior for \(\tau^2\) when \(a=b=\epsilon\) with \(\epsilon\) small for a given design matrix and prior precision matrix such that approximately \(P(|f(x_{k}|\le c,k=1,\ldots,p)\ge 1-\alpha\) When a unequal to a the shape parameter a has to be specified.

Usage

get_theta_ig(alpha = 0.01, method = "integrate", Z, c = 3,
  eps = .Machine$double.eps, Kinv, equals = FALSE, a = 1,
  type = "marginalt")

Arguments

alpha

denotes the 1-\(\alpha\) level.

method

with integrate as default. Currently no further method implemented.

Z

the design matrix.

c

denotes the expected range of the function.

eps

denotes the error tolerance of the result, default is .Machine$double.eps.

Kinv

the generalised inverse of K.

equals

saying whether a=b. The default is FALSE due to the fact that a is a shape parameter.

a

is the shape parameter of the inverse gamma distribution, default is 1.

type

is either numerical integration (integrate) of to obtain the marginal distribution of \(z_p'\beta\) or the theoretical marginal t-distribution (marginalt). marginalt is the default value.

Value

an object of class list with values from uniroot.

Details

Currently, the implementation only works properly for the cases a unequal b.

References

Nadja Klein and Thomas Kneib (2015). Scale-Dependent Priors for Variance Parameters in Structured Additive Distributional Regression. Working Paper.

Stefan Lang and Andreas Brezger (2004). Bayesian P-Splines. Journal of Computational and Graphical Statistics, 13, 183-212.

Examples

Run this code
# NOT RUN {
set.seed(123)
library(MASS)
# prior precision matrix (second order differences) 
# of a spline of degree l=3 and with m=20 inner knots
# yielding dim(K)=m+l-1=22
K <- t(diff(diag(22), differences=2))%*%diff(diag(22), differences=2)
# generalised inverse of K
Kinv <- ginv(K)
# covariate x
x <- runif(1)
Z <- matrix(DesignM(x)$Z_B,nrow=1)
theta <- get_theta_ig(alpha = 0.01, method = "integrate", Z = Z, 
                      c = 3, eps = .Machine$double.eps, Kinv = Kinv, 
					 equals = FALSE, a = 1, type="marginalt")$root

# }

Run the code above in your browser using DataLab