logp.u: Unnormalized log-posterior probability of a model.

Description Usage Arguments Value Details Examples

View source: R/logp.R

Description

Unnormalized log-posterior of a model.

Usage

1
logp.u(model, X, y, lam, w)

Arguments

model

An integer vector containing the model

X

An n x p matrix. Sparse matrices are supported and every care is taken not to make copies of this (typically) giant matrix. No need to center or scale.

y

The response vector of length n.

lam

The slab precision parameter.

w

The prior inclusion probability of each variable.

Value

The unnormalized probability of the model (see detail).

Details

The unnormalized posterior probability of the model model is given by

0.5p_{0}\log(lam) - 0.5*\log\det(A) - 0.5*(n-1)*\log(RSS) + p_{0}*\log(w/(1-w))

where

  1. p_{0} = length(model), the model size,

  2. Xs = scale(X[,model]),

  3. A = crossprod(Xs) + lam I,

  4. ys = scale(y), so that sum(ys^2) = n-1 and

    RSS = n-1 - ys^{T}Xs A^{-1}Xs^{T}ys

    ,

Obviously the computations are not as bruteforce as in pseudocode above.

Examples

1
2
3
4
5
6
7
## Not run: 
set.seed(1234)
X <- matrix(runif(100*200),100,200)
y <- 1 + X[,1:5]%*%rep(5,5) + 0.4*rnorm(100)
logp.u(model = 1:5,X = X,y = y,lam = 0.001,w = 1/200) # -20.2828

## End(Not run)

Run-Wang/bsvs documentation built on Aug. 18, 2021, 9:42 p.m.