Mean of tilted discrete distributions

DESCRIPTION:

Calculate the mean of exponentially-tilted or maximum-likelihood-tilted discrete distributions, or find the tilting parameter for a desired mean.

USAGE:

tiltMean(tau, L, tilt="exponential", weights=NULL, group=NULL,  
              lambda = NULL, tol=1e-06, maxiter=50) 
tiltMeanSolve(q, L, tilt="exponential", weights=NULL, group=NULL, 
              initial, tol=1e-06, tol.tau=tol, maxiter=50) 

REQUIRED ARGUMENTS:

tau
vector of tilting parameters.
q
vector of desired tilted means.
L
vector of values which determine a discrete distribution.

OPTIONAL ARGUMENTS:

tilt
one of "exponential" or "ml", for exponential or maximum likelihood tilting, respectively.
weights
vector the same length of L, if the discrete distribution has unequal probabilities on the values (before tilting).
group
vector the same length as L; unique values of this vector determine groups, for multiple-sample applications or stratified sampling.
lambda
matrix with one row for each group and one column for each value of tau containing normalizing constants for maximum likelihood tilting with groups (see DETAILS below, and ). These are computed if not provided.
initial
vector the same length as q, initial values used in iteratively solving for tau.
tol
For tiltMeanSolve, find tau so the tilted mean is within tol of q. For tiltMean, find lambda values such that tilting weights sum within each group to within tol of 1.
tol.tau
tolerance for solving for tau on the scale of tau.
maxiter
maximum number of iterations allowed for finding values of tau which bracket the solution for each q (after the root is bracketed additional iterations may be performed).

VALUE:

For tiltMean, a list with components
tau
the input tilting parameter, and
q
vector of the same length as tau, containing weighted means for the tilted distributions.
lambda
matrix of normalizing constants, one column for each value of tau and number of rows (or length) equal to the unique values of group. This is present only if tilt="ml" and there are multiple groups.

For tiltMeanSolve, the returned list has component

q
the input
tau.exp
vector the same length as q, tilting parameters that give the desired tilted mean.
tau.ml
maximum likelihood tilting parameter(s); present only if tilt="ml".
lambda
matrix of normalizing constants, as for tiltMean; present only if tilt="ml" and there are multiple groups.

DETAILS:

In the univariate case ( L a vector and tau a scalar) with only one group, exponential tilting places probability proportional to

    weights * exp((L-Lbar) * tau) 

on the values in L, where Lbar is the weighted mean of L. Maximum likelihood tilting places probabilities proportional to
    weights / (1 - (L-Lbar) * tau) 

For further details, and formulae in the group case (multiple samples, or stratified sampling), see .

REFERENCES:

Hesterberg, T.C. (2003), "Tilting Calculations for Resampling Inferences and Approximations", Research Report No. 103, Research Department, Insightful Corp., 1700 Westlake Ave. N., Suite 500, Seattle, WA 98109.

SEE ALSO:

, , ,

EXAMPLES:

# Hypothesis testing; find a weighted empirical distribution 
# for which the weighted mean is 0.0: 
x <- rnorm(20) 
tau <- tiltMeanSolve(0.0, x, tilt="ml")$tau.ml 
wt <- tiltWeights(tau, x, tilt="ml") 
mean(x, weights=wt)  # equal to zero, within given tolerance 
# likelihood ratio statistic for empirical likelihood test 
-2 * sum(log(20 * wt)) 
 
# stratified data: tilt so weighted mean is average of the group 
# medians. 
set.seed(0) 
gs <- c(10,20,10) 
L1 <- rnorm(gs[1],mean=0,sd=1) 
L2 <- rnorm(gs[2],mean=1,sd=1) 
L3 <- rnorm(gs[3], mean=2, sd=3) 
L <- c(L1,L2,L3) 
group <- rep(1:3,gs) 
Q <- mean(c(median(L1), median(L2), median(L3))) 
tiltMeanSolve(Q, L, group=group, tilt="ml") 
 
# Demonstrate relationship between overall and group tilting parameters 
set.seed(1) 
x <- runif(25) 
tiltMean(.1, x, group=rep(1:2, c(10,15)))$q 
(mean(x[1:10],  weights=exp(.1 /(10/25) * x[1:10]))  + 
 mean(x[11:25], weights=exp(.1 /(15/25) * x[11:25])) ) 
tiltMean(.1 /(10/25), x[1:10])$q + tiltMean(.1 /(15/25), x[11:25])$q 
# all three match