tri.npmle: Trivariate NPMLE

Description Usage Arguments Value Examples

Description

General nonparametric maximum likelihood estimation for a trivariate mixing distribution, implemented using EM. Assumes that the observed data are triples (X_{1i},X_{2i},X_{3i}) with marginal likelihood

\int f_1(X_{1i};u_1)f_2(X_{2i};u_2)f_3(X_{3i};u_3)dG(u_1,u_2,u_3),

where G is the mixing distribution to be estimated. Suppose there are p observed tuples and G is to be estimated on a grid of d1 x d2 x d3 points.

Usage

1
tri.npmle(D1, D2, D3, maxit = 200, tol = 1e-04, verbose = FALSE)

Arguments

D1

p x d1 matrix of conditional density values, where the ijth entry is f_1(X_{1i};u_{1j}).

D2

p x d2 matrix of conditional density values, where the ijth entry is f_2(X_{2i};u_{2j}).

D3

p x d3 matrix of conditional density values, where the ijth entry is f_3(X_{3i};u_{3j}).

maxit

maximum number of EM iterations

tol

error tolerance

verbose

TRUE to print the error attained by each EM iteration

Value

g

d1 x d2 x d3 array of probability masses at each grid point

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## generate parameters from mixing distribution
p <- 1000;
set.seed(1);
theta1 <- rnorm(p);
theta2 <- -theta1+rnorm(p);
theta3 <- 0.5*theta1+theta2+rnorm(p);
## generate observed variables
X1 <- rnorm(p,theta1,1);
X2 <- rnorm(p,theta2,1);
X3 <- rnorm(p,theta3,1);
## set grid points
d1 <- 15; d2 <- 20; d3 <- 25;
Theta1 <- seq(min(X1),max(X1),length=d1);
Theta2 <- seq(min(X2),max(X2),length=d2);
Theta3 <- seq(min(X3),max(X3),length=d3);
## calculate D matrices
D1 <- outer(X1,Theta1,function(x,y){
  dnorm(x,y,1);
});
D2 <- outer(X2,Theta2,function(x,y){
  dnorm(x,y,1);
});
D3 <- outer(X3,Theta3,function(x,y){
  dnorm(x,y,1);
});
## fit npmle
g <- tri.npmle(D1,D2,D3);
par(mfrow=c(1,3));
contour(Theta1,Theta2,apply(g,c(1,2),sum));
points(theta1,theta2);
contour(Theta1,Theta3,apply(g,c(1,3),sum));
points(theta1,theta3);
contour(Theta2,Theta3,apply(g,c(2,3),sum));
points(theta2,theta3);

ssa documentation built on May 1, 2019, 10:27 p.m.