| prior_loglik | R Documentation |
Evaluates the log-prior on the spline coefficients conditional on the dispersion and penalty matrices.
prior_loglik(
model_fit,
B_predict = NULL,
sigmasq_predict = NULL,
include_constant = TRUE,
...
)
model_fit |
An lgspline model object. |
B_predict |
Optional list of coefficient vectors at which to evaluate the prior. Default NULL uses the fitted coefficients. |
sigmasq_predict |
Numeric scalar dispersion parameter. If NULL,
|
include_constant |
Logical; if TRUE (default), include the multivariate normal normalizing constant. |
... |
Optional legacy arguments. |
Returns the quadratic form of \beta^{T}\Lambda\beta evaluated at the
tuned or fixed penalties, scaled by negative one-half inverse dispersion.
Assuming fixed penalties, the prior on \beta is taken to be
\beta | \sigma^2 \sim \mathcal{N}(\textbf{0}, \sigma^2\Lambda^{-1})
so that, up to a normalizing constant C with respect to \beta,
\implies \log P(\beta|\sigma^2) = C-\frac{1}{2\sigma^2}\beta^{T}\Lambda\beta
The value of C is included when include_constant = TRUE, and
omitted when FALSE.
This is useful for computing joint penalized log-likelihoods and related
MAP-style diagnostics for a fitted lgspline object.
A numeric scalar representing the prior log-likelihood.
lgspline
## Data
t <- sort(runif(100, -5, 5))
y <- sin(t) - 0.1*t^2 + rnorm(100)
## Model keeping penalties fixed
model_fit <- lgspline(t, y, opt = FALSE)
## Full joint log-likelihood, conditional upon known sigma^2 = 1
jntloglik <- sum(dnorm(model_fit$y,
model_fit$ytilde,
1,
log = TRUE)) +
prior_loglik(model_fit, sigmasq_predict = 1)
print(jntloglik)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.