get_theta_gbp: Find Scale Parameter for Generalised Beta Prime (Half-Cauchy)...

Description Usage Arguments Value Author(s) References Examples

View source: R/get_theta_gbp.r

Description

This function implements a optimisation routine that computes the scale parameter θ of the gamma prior for τ^2 (corresponding to a half cauchy for τ) for a given design matrix and prior precision matrix such that approximately P(|f(x_{k}|≤ c,k=1,…,p)≥ 1-α

Usage

1
2
get_theta_gbp(alpha = 0.01, method = "integrate", Z, c = 3,
  eps = .Machine$double.eps, Kinv)

Arguments

alpha

denotes the 1-α 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.

Value

an object of class list with values from uniroot.

Author(s)

Nadja Klein

References

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

Andrew Gelman (2006). Prior Distributions for Variance Parameters in Hierarchical Models. Bayesian Analysis, 1(3), 515–533.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
set.seed(123)
require(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_gbp(alpha = 0.01, method = "integrate", Z = Z, 
                            c = 3, eps = .Machine$double.eps, Kinv = Kinv)$root

## Not run: 

set.seed(91179)
library(BayesX)
library(MASS)
# prior precision matrix to zambia data set
K <- read.gra(system.file("examples/zambia.gra", package="sdPrior"))
# generalised inverse of K
Kinv <- ginv(K)

# read data
dat <- read.table(system.file("examples/zambia_height92.raw", package="sdPrior"), header = TRUE)

# design matrix for spatial component
Z <- t(sapply(dat$district, FUN=function(x){1*(x==rownames(K))}))

# get scale parameter
theta <- get_theta_gbp(alpha = 0.01, method = "integrate", Z = Z, 
                            c = 3, eps = .Machine$double.eps, Kinv = Kinv)$root

## End(Not run) 

sdPrior documentation built on May 2, 2019, 8:57 a.m.