% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/prior_loglik.R
\name{prior_loglik}
\alias{prior_loglik}
\title{Log-Prior Distribution Evaluation for lgspline Models}
\usage{
prior_loglik(model_fit, sigmasq = NULL, include_constant = TRUE)
}
\arguments{
\item{model_fit}{An lgspline model object.}

\item{sigmasq}{Numeric scalar dispersion parameter. If NULL,
\code{model_fit$sigmasq_tilde} is used.}

\item{include_constant}{Logical; if TRUE (default), include the
multivariate normal normalizing constant.}
}
\value{
A numeric scalar representing the prior log-likelihood.
}
\description{
Evaluates the log-prior on the spline coefficients conditional on the
dispersion and penalty matrices.
}
\details{
Returns the quadratic form of \eqn{\beta^{T}\Lambda\beta} evaluated at the
tuned or fixed penalties, scaled by negative one-half inverse dispersion.

Assuming fixed penalties, the prior on \eqn{\beta} is taken to be
\deqn{\beta | \sigma^2 \sim \mathcal{N}(\textbf{0}, \sigma^2\Lambda^{-1})}
so that, up to a normalizing constant \eqn{C} with respect to \eqn{\beta},
\deqn{\implies \log P(\beta|\sigma^2) = C-\frac{1}{2\sigma^2}\beta^{T}\Lambda\beta}

The value of \eqn{C} is included when \code{include_constant = TRUE}, and
omitted when \code{FALSE}.

This is useful for computing joint penalized log-likelihoods and related
MAP-style diagnostics for a fitted \code{lgspline} object.
}
\examples{

\donttest{
## 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 = 1)
print(jntloglik)
}

}
\seealso{
\code{\link{lgspline}}
}
