Learn R Programming

icmm (version 1.2)

get.wpost: Estimate posterior probability of mixing weight.

Description

With the Ising prior on structured predictors, this function gets the posterior probability of mixing weight.

Usage

get.wpost(SS, beta, alpha, hyperparam, structure, edgeind, j)

Arguments

SS

a scalar value of sufficient statistic for regression coefficient.

beta

a (p*1) matrix of regression coefficients.

alpha

a scalar value of hyperparameter alpha.

hyperparam

a two-dimensional vector of hyperparameters a and b.

structure

a data frame stores the information of structure among predictors.

edgeind

a vector stores primary keys of structure.

j

an index ranges from 1 to p. This function estimates a posterior probability of a mixing weight corresponding to predictor j.

Value

Return a scalar value of a posterior probability of mixing weight for predictor.

Details

With the Ising prior on structured predictors, the problem is transformed into the realm of empirical Bayes thresholding with Laplace prior by estimating the posterior probability of mixing weight. The posterior probability is used to find the posterior median of a regression coefficient.

Examples

Run this code
# NOT RUN {
data(simGaussian)
Y<-as.matrix(simGaussian[,1])
X<-as.matrix(simGaussian[,-1])
n<-dim(X)[1]
data(linearrelation)
edgeind<-sort(unique(linearrelation[,1]))
# Obtain initial values from lasso
data(initbetaGaussian)
beta<-as.matrix(initbetaGaussian)
# Initiate all other parameters
alpha<-0.5
# }
# NOT RUN {
sigma<-get.sigma(Y=Y, X=X, beta=beta, alpha=alpha)
# }
# NOT RUN {
hyperparam<-get.ab(beta, linearrelation, edgeind)
# }
# NOT RUN {
# Estimate the posterior probability of first predictor
j<-1
Yres<-Y-X%*%beta+X[,j]*beta[j,1]
sxy<-t(Yres)%*%X[,j]
ssx<-sum(X[,j]^2)
# }
# NOT RUN {
SS<-sqrt(n-1)*sxy/(sigma*ssx)
# }
# NOT RUN {
wpost<-get.wpost(SS=SS, beta=beta, alpha=alpha, hyperparam=hyperparam, 
       structure=linearrelation, edgeind=edgeind, j=j)
# }

Run the code above in your browser using DataLab