Description Usage Arguments Value Examples
General nonparametric maximum likelihood estimation for a univariate mixing distribution, implemented using EM. Assumes that the observed data are X_i with marginal likelihood
\int f(X_i;u)dG(u),
where G is the mixing distribution to be estimated. Suppose there are p observations and G is to be estimated on a grid of d points.
1 |
D |
p x d matrix of conditional density values, where the ijth entry is f(X_i;u_j) |
maxit |
maximum number of EM iterations |
tol |
error tolerance |
verbose |
TRUE to print the error attained by each EM iteration |
g |
d x 1 vector of probability masses at each grid point |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## generate parameters from mixing distribution
p <- 1000;
set.seed(1); theta <- rnorm(p);
## generate observed variables
X <- rnorm(p,theta,1);
## set grid points
d <- 25;
Theta <- seq(min(X),max(X),length=d);
## calculate D matrix
D <- outer(X,Theta,function(x,y){
dnorm(x,y,1);
});
## fit npmle
g <- uni.npmle(D);
plot(Theta,g/sum(g*(Theta[2]-Theta[1])),type="l");
lines(Theta,dnorm(Theta),col="red");
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.