## Greene( 2003 ): example 22.8, page 786
data( Mroz87 )
Mroz87$kids <- ( Mroz87$kids5 + Mroz87$kids618 > 0 )
greene <- heckit( wage ~ exper + I( exper^2 ) + educ + city,
lfp ~ age + I( age^2 ) + faminc + kids + educ, Mroz87 )
summary( greene ) # print summary
summary( greene$probit ) # summary of the 1st step probit estimation
# this is Example 21.4, p. 681f
greene$sigma # estimated sigma
greene$rho # estimated rho
## Wooldridge( 2003 ): example 17.5, page 590
data( Mroz87 )
wooldridge <- heckit( log( wage ) ~ educ + exper + I( exper^2 ),
lfp ~ nwifeinc + educ + exper + I( exper^2 ) + age + kids5 + kids618, Mroz87 )
summary( wooldridge ) # summary of the 1st step probit estimation
# (Example 17.1, p. 562f) and 2nd step OLS regression
wooldridge$sigma # estimated sigma
wooldridge$rho # estimated rho
## example using random numbers
nObs <- 1000
myData <- data.frame( no = c( 1:nObs ), x1 = rnorm( nObs ), x2 = rnorm( nObs ) )
myData$y <- 2 + myData$x1 + 0.9 * rnorm( nObs )
myData$s <- ( 2 * myData$x1 + myData$x2 + 4 * rnorm( nObs ) - 0.2 ) > 0
myData$y[ !myData$s ] <- NA
myHeckit <- heckit( y ~ x1, s ~ x1 + x2, myData, print.level = 1 )
## example using random numbers with IV/2SLS estimation
nObs <- 1000
myData <- data.frame( no = c( 1:nObs ), x1 = rnorm( nObs ), x2 = rnorm( nObs ),
u = 0.5 * rnorm( nObs ) )
myData$w <- 1 + myData$x1 + 0.2 * myData$u + 0.1 * rnorm( nObs )
myData$y <- 2 + myData$w + myData$u
myData$s <- ( 2 * myData$x1 + myData$x2 + 4 * rnorm( nObs ) - 0.2 ) > 0
myData$y[ !myData$s ] <- NA
myHeckit <- heckit( y ~ w, s ~ x1 + x2, data = myData,
inst = ~ x1, print.level = 1 )
Run the code above in your browser using DataLab