hyperpar {sdPrior}R Documentation

Find Scale Parameters for Inverse Gamma Hyperprior of Nonlinear Effects with Spike and Slab Prior (Simulation-based)

Description

This function implements a optimisation routine that computes the scale parameter bb and selection parameter rr. . Here, we assume an inverse gamma prior IG(aa,bb) for ψ2\psi^2 and τ2N(0,r(δ)ψ2)\tau^2\sim N(0,r(\delta)\psi^2) and given shape paramter aa, such that approximately P(f(x)cspike,xD)1α1P(f(x)\le c|spike,\forall x\in D)\ge 1-\alpha1 and P(xDs.t.f(x)cslab)1α2P(\exists x\in D s.t. f(x)\ge c|slab)\ge 1-\alpha2.

Usage

hyperpar(Z, Kinv, a = 5, c = 0.1, alpha1 = 0.1, alpha2 = 0.1,
  R = 10000, myseed = 123)

Arguments

Z

the row of the design matrix (or the complete matrix of several observations) evaluated at.

Kinv

the generalised inverse of KK.

a

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

c

denotes the expected range of eqnf .

alpha1

denotes the 1-α1\alpha1 level for bb.

alpha2

denotes the 1-α2\alpha2 level for rr.

R

denotes the number of replicates drawn during simulation.

myseed

denotes the required seed for the simulation based method.

Value

an object of class list with root values rr, bb from uniroot.

Author(s)

Nadja Klein

References

Nadja Klein, Thomas Kneib, Stefan Lang and Helga Wagner (2016). Spike and Slab Priors for Effect Selection in Distributional Regression. Working Paper.

Examples

set.seed(123)
library(MASS)
# prior precision matrix (second order differences) 
# of a spline of degree l=3 and with m=22 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 (same as if we used mixed model representation!)
Kinv <- ginv(K)
# covariate x
x <- runif(1)
Z <- matrix(DesignM(x)$Z_B,nrow=1)
fgrid <- seq(-3,3,length=1000)
mdf <- hyperpar(Z,Kinv,a=5,c=0.1,alpha1=0.05,alpha2=0.05,R=10000,myseed=123)


[Package sdPrior version 1.0-0 Index]