GaussianNPML: Nonparametric Maximum Likelihood estimation, Gaussian

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

View source: R/hhsim.R

Description

Implements the nonparametric maximum likelihood estimation (NPML) estimate of g(theta).

Usage

1
2
3
4
5
6
GaussianNPML(Y,
             sigma2=rep(1,length(Y)),
             mu=Y,
             alpha=rep(1/length(Y),length(Y)),
             tolerance=0.0001,
             verbose=FALSE)

Arguments

Y

vector of data points

sigma2

vector of known variances

mu

vector of initial mass points for the NPML

alpha

vector of initial weights on each mass point, mu

tolerance

absolute change in thetas before considered converged

verbose

indicator of whether to print progress information

Details

Assumes a model of the form Y[k]~N(theta[k],sigma[k]) where theta[k]~g(theta). This function gets posterior means for theta using the NPML estimate for g. It uses the EM algorithm to solve for g. No attempt is made to merge very close mass points since our main interest is in estimates of theta[k].

Value

theta

empirical Bayes posterior mean estimates of theta

sigma2

estimates of sigma2 (currently not estimated, assumed known)

mu

mass points from the NPML

alpha

probability mass for each mu

Author(s)

Greg Ridgeway gregr@rand.org

References

Laird N.M. (1982). Empirical Bayes estimate using the non-parametric maximum likelihood estimate of the prior. Journal of Statistical Computation and Simulation, 15:211-220.

See Also

GaussianSBR

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
k <- 100
theta <- rnorm(k,0,1)
sigma <- rep(1,k)
Y <- rnorm(k,theta,sigma)

out.npml  <- GaussianNPML(Y,sigma^2)
x <- with(out.npml, sample(mu,size=100000,replace=TRUE,prob=alpha))
hist(x,main="NPML",prob=TRUE,xlab="theta",ylab="g(theta)")

plot(out.npml$theta,theta)

gregridgeway/hhsim documentation built on May 17, 2019, 8:36 a.m.