HeckmanEM: Fit the Normal or Student-t Heckman Selectio model.

Description Usage Arguments Value Examples

View source: R/HeckmanEM.R

Description

'HeckmanEM()' fit the Heckman selection model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
HeckmanEM(
  y,
  x,
  w,
  cc,
  nu = 4,
  family = "T",
  error = 1e-05,
  iter.max = 500,
  im = TRUE,
  criteria = TRUE
)

Arguments

y

A response vector.

x

A covariate matrix for the response y.

w

A covariate matrix for the missing indicator cc.

cc

A missing incidator vector (1=obserced, 0=missing) .

nu

The initial value for the degrees of freedom.

family

The family to be used (Normal or T).

error

The abslute convergence error for the EM stopping rule.

iter.max

The maximum number of iterations for the EM algorithm.

im

TRUE/FALSE, boolean to decide if the standard erros of the parameters should be computed.

criteria

TRUE/FALSE, boolean to decide if the model selection criteria should be computed.

Value

An object of the class HeckmanEM with all the outputs provided from the function.

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
n <- 100
family <- "T"
nu <- 4
rho <- .6
cens <- .25

set.seed(20200527)
w <- cbind(1,runif(n,-1,1),rnorm(n))
x <- cbind(w[,1:2])
c <- qt(cens, df=nu)

sigma2 <- 1

beta <- c(1,0.5)
gamma <- c(1,0.3,-.5)
gamma[1] <- -c*sqrt(sigma2)

set.seed(1)
datas <- rHeckman(x,w,beta,gamma,sigma2,rho,nu,family=family)
y <- datas$y
cc <- datas$cc

# Normal EM
res.N <- HeckmanEM(y, x, w, cc, nu = 4, family="Normal", error = 1e-05, iter.max = 50,
                   im=TRUE, criteria = TRUE)
# Student-t: EM
res.T <- HeckmanEM(y, x, w, cc, nu = 4, family="T", error = 1e-05, iter.max = 50,
                   im=TRUE, criteria = TRUE)

HeckmanEM documentation built on May 19, 2021, 5:07 p.m.