mle_ls: Maximum Likeihood Estimate

Description Usage Arguments Details Value Examples

View source: R/ls_functions.R

Description

Computes the maximum likelihood estimate for the latent stratification model, optionally takes starting values in original parameter space.

Usage

1
mle_ls(data, start = NULL, starts = 1, vcv = "hessian", quiet = FALSE)

Arguments

data

data frame containing cols y (positive outcome with zeros) and z (treatment).

start

vector starting values for parameters c(piA, piB, muA1, muA0, muB1, sigma).

starts

number of starting values.

vcv

the variance-covariance matrix of the data, can be calculated using ls_vcv().

quiet

boolean controlling if the computation time should be printed after execution.

Details

If starts=1, then the optimization is run once from the starting values. If starts>1, then mle optimization is done with multiple starting values.
The output is an object, which can be called using summary() to show the ATE parameters, their standard errors, and the maximum likelihood. To access the variance-covariance matrix, use $vcv.
For the input data frame, column z is the dummy variable for treatment. If z = 1, then the observation has received treatment. If z = 0, then the observation has not received treatment.
For the \empthvcv parameter:
if vcv = "hessian" then the standard errors are computed by the numeric hessian
if vcv = "score" then standard errors are computed from the gradient
if vcv = "robust" then white robust standard errors are computed
if vcv = "bootstrap" then the standard errors are computed by bootstrap
The function uses L-BFGS-B method for optimization. According to RDocumentation, it is taken from Byrd et. al. (1995), allowing box constraints with upper and lower bound.
If quiet=TRUE, then the time to optimize and calculate the variance covariance matrix will be displayed along with the results.

Value

object containing the MLE results.

Examples

1
2
3
4
5
6
7
8
9
sim = sim_latent_strat(n=10000, piA=0.2, piB=0.1, muA1=5, muA0=4.5, muB1=3, sigma=0.3)
mle_ls(sim$data)

# if you wish to start the optimization in 3 places
mle_ls(sim$data, starts=3)

# if you wish to identify the starting values yourself
startv = c(0.2, 0.1, 5, 4.5, 3, 0.3)
mle_ls(sim$data, start=startv)

zthuang0422/PURM-2021-Latent-Stratification documentation built on Dec. 23, 2021, 10:12 p.m.