## We estimate a tobit-2 model and print the loglik value
library(mvtnorm)
N <- 500
vc <- diag(2)
vc[2,1] <- vc[1,2] <- -0.7
eps <- rmvnorm(N, rep(0, 2), vc)
xs <- runif(N)
ys <- xs + eps[,1] > 0
xo <- runif(N)
yo <- (xo + eps[,2])*(ys > 0)
a <- selection(ys~xs, yo ~xo)
loglikValue(a) # this values is also printed by 'summary'
Run the code above in your browser using DataLab