R/penalties.R

Defines functions P2.mat P1.mat

Documented in P1.mat P2.mat

#' Generate a Penalty Matrix
#'
#' @param K An integer dimensino value.
#'
#' @return A first-order difference penalty matrix.
#' @keywords internal
P1.mat <- function(K) {
  P <- diff(diag(K))
  t(P) %*% P
}

#' Generate a Penalty Matrix
#'
#' @param K An integer dimensino value.
#'
#' @return A second-order difference penalty matrix.
#' @keywords internal
P2.mat <- function(K) {
  P <- diff(diff(diag(K)))
  t(P) %*% P
}

Try the BayesDecon package in your browser

Any scripts or data that you put into this service are public.

BayesDecon documentation built on March 15, 2026, 1:06 a.m.