Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

impsampling

Importance sampling using a t proposal density


Description

Implements importance sampling to compute the posterior mean of a function using a multivariate t proposal density

Usage

impsampling(logf,tpar,h,n,data)

Arguments

logf

function that defines the logarithm of the density of interest

tpar

list of parameters of t proposal density including the mean m, scale matrix var, and degrees of freedom df

h

function that defines h(theta)

n

number of simulated draws from proposal density

data

data and or parameters used in the function logf

Value

est

estimate at the posterior mean

se

simulation standard error of estimate

theta

matrix of simulated draws from proposal density

wt

vector of importance sampling weights

Author(s)

Jim Albert

Examples

data(cancermortality)
start=c(-7,6)
fit=laplace(betabinexch,start,cancermortality)
tpar=list(m=fit$mode,var=2*fit$var,df=4)
myfunc=function(theta) return(theta[2])
theta=impsampling(betabinexch,tpar,myfunc,1000,cancermortality)

LearnBayes

Functions for Learning Bayesian Inference

v2.15.1
GPL (>= 2)
Authors
Jim Albert
Initial release
2018-03-18

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.