npmixapply: Apply Functions over estimated unit-specific posterior...

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/npmixapply.R

Description

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

Usage

1
npmixapply(object, FUN, ...)

Arguments

object

an object of class "npmix"

FUN

a user provided function

...

optional arguments to FUN

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|θ_i ~ p(x|θ_i,η_i) and θ_i ~ F for i = 1,...,n.

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

Value

a vector with length equal to n

Author(s)

Nicholas Henderson

See Also

npmle

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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})

## End(Not run)

rvalues documentation built on March 11, 2021, 9:05 a.m.

Related to npmixapply in rvalues...