Learn R Programming

diagis (version 0.2.3)

weight_plot: Diagnostic plot of importance sampling weights

Description

Function weight_plot plots four figures given the weight vector w: Plot of largest weights, sorted graph of all weights, running variance estimate of weights, and running effective sample size estimate of weights.

Usage

weight_plot(w)

Arguments

w

Vector of weights.

Examples

Run this code
#' importance sampling from too narrow distribution
#' weights have infinite variance
set.seed(1)
x_inf <- rnorm(1000, sd = 0.1)
w_inf <- dnorm(x_inf) / dnorm(x_inf, 0, 0.1)
weight_plot(w_inf)
x_opt <- rnorm(1000, sd = sqrt(2))
w_opt <- dnorm(x_opt) / dnorm(x_opt, 0, sqrt(2))
weight_plot(w_opt)

Run the code above in your browser using DataLab