rvalues (version 0.6.3)

npmixapply: Apply Functions over estimated unit-specific posterior distributions

Description

Using a nonparametric estimate of the mixing distribution, computes a posterior quantity of interest for each unit.

Usage

npmixapply(object, FUN, ...)

Arguments

object

an object of class "npmix"

FUN

a user provided function

optional arguments to FUN

Value

a vector with length equal to \(n\)

Details

object is an object of class "npmix" containing a nonparametric estimate of the mixing distribution \(F\) in the following two-level sampling model \( X_i|\theta_i\) ~ \(p(x|\theta_i,\eta_i)\) and \(\theta_i\) ~ \(F\) for \(i = 1,...,n\).

Using npmixapply(object, f), then returns the posterior expectation of \(f\): \( E[ f(\theta_i) | X_i, \eta_i] \), for \(i = 1,...,n\).

See Also

npmle

Examples

Run this code
# NOT RUN {
data(hiv)
npobj <- npmle(hiv, family = gaussian, maxiter = 4)

### Compute unit-specific posterior means
pmean <- npmixapply(npobj, function(x) { x })

### Compute post. prob that \theta_i < .1
pp <- npmixapply(npobj, function(x) { x < .1})
# }

Run the code above in your browser using DataLab