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

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

`alpha` |
denotes the 1- |

`method` |
with |

`Z` |
the design matrix. |

`c` |
denotes the expected range of the function. |

`eps` |
denotes the error tolerance of the result, default is |

`Kinv` |
the generalised inverse of K. |

an object of class `list`

with values from `uniroot`

.

Nadja Klein

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.

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
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_aunif(alpha = 0.01, method = "integrate", Z = Z,
c = 3, eps = .Machine$double.eps, Kinv = Kinv)$root
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.