setlogP: Calculate constants used during sampling from Likelihood...

Description Usage Arguments Value Examples

View source: R/EnvsetlogP.R

Description

This function computes two vectors of constants needed during sampling. The first is used to determine the probability with which each component of the grid should be visited, while the second is used as a constants when calculating acceptance rates.

Usage

1
setlogP(logP, NegLL, cbars, G3)

Arguments

logP

A matrix that typically contains two columns and information for each component of the grid. The first column will typically hold the final output from the Set_Grid function, which is the density associated with the related restricted normal.

NegLL

A vector with evaluations of the Negative Log-likelihood for each of the components of the grid.

cbars

A matix holding the gradients for the Negative of the Log-likelihood for each of the componentsof the grid.

G3

A matrix containing the set of tangent points used in the grid.

Value

Refer to Nygren and Nygren (2006) for details. The first .

logP

The first column holds the value passed into the function while the second contains the log of the (un-normalized) probabilities with which each of the components of the grid should be visited. This corresponds to the log of the denominator components used to compute p_i in remark 6 in Nygren and Nygren (2006)

LLconst

This holds a vector of constants used as upper bounds when deriving acceptance rates during the accept-reject sampling process. This constant corresponds to the denominator for the function h() in Theorem 1 of Nygren and Nygren (2006). During the sampling, the log of the numerator of the same function if evaluated for each candidate and the difference between the candidate value and this constant is used to determine the acceptance rate to use when evaluating acceptance of the candidate. If the evaluated value for the candidate is close to this constant, then the chance of acceptance rate is high. If it is much smaller, then the chance of acceptance is low.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## ----dobson-------------------------------------------------------------------
## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)

## Prior mean vector 
mu<-matrix(0,5)           
mu[1,1]=log(mean(counts)) 
## Prior standard deviation and Variance
mysd<-1           
V=((mysd)^2)*diag(5)  
## Call to glmb
glmb.D93<-glmb(n=1000,counts ~ outcome + treatment,
               family = poisson(),pfamily=dNormal(mu=mu,Sigma=V))
## ----glmb extractAIC-------------------------------------------------------------
extractAIC(glmb.D93)

knygren/glmbayes documentation built on Sept. 4, 2020, 4:39 p.m.