Memuat
Memuat
Tobit and Heckman Selection Models for Human Resource Management
0 views
Using synthetic data for illustration, this analysis aims to estimate the effect of targets and wages on overtime hours censored at zero. The Tobit model handles a dependent variable censored at zero (many zero observations), while the Heckman selection model corrects the bias when the outcome is only observed for participants. It suits theses on spending, hours or wages that are often zero or unobserved.

Using synthetic data for illustration, this analysis aims to estimate the effect of targets and wages on overtime hours censored at zero.
| Role | Variable | Unit |
|---|---|---|
| Main | Monthly overtime hours | hours |
| Supporting 1 | Work target load | score |
| Supporting 2 | Hourly wage | IDR thousand |
41.2% of Monthly overtime hours observations are zero, so OLS (Work target load coefficient 0.965) is biased towards zero relative to the Tobit model (1.474; p < 0.001). The two-step Heckman model gives 1.012 for participants; the inverse Mills ratio (p = 0.002, rho = 0.72) indicates significant selection bias, so the Heckman correction matters.
Computed from illustrative synthetic data, not from a real study.
The Tobit model handles a dependent variable censored at zero (many zero observations), while the Heckman selection model corrects the bias when the outcome is only observed for participants. It suits theses on spending, hours or wages that are often zero or unobserved.
Report the share of zeros, then compare the OLS, Tobit and Heckman coefficients to show the OLS bias. Tobit coefficients are effects on the latent variable, Heckman coefficients are effects for participants, and a significant inverse Mills ratio (non-zero rho) signals selection bias.
A short starting script with this project's variable names. The delivered version is adapted to your data and fully commented.
# Contoh kode R: Tobit and Heckman Selection Models
suppressPackageStartupMessages({
library(ggplot2)
library(patchwork)
library(AER)
library(sampleSelection)
})
set.seed(42)
# ---- Gaya grafik ----
pal <- c("#1f6feb", "#e8590c", "#2f9e44", "#ae3ec9", "#f59f00")
warna <- list(bg = "#f4f6fa", panel = "#ffffff", teks = "#1f2933", redup = "#5f6b78", grid = "#e3e8ee", bar = "#1d3557")
tata <- 1
theme_set(theme_minimal(base_size = 11) + theme(legend.position = "bottom"))
# ---- Data sintetis: Y bernilai nol untuk yang tidak berpartisipasi ----
n <- max(300, 200)
d <- data.frame(work_target_load = round(rnorm(n, 50, 10), 3),
hourly_wage = round(rnorm(n, 30, 6), 3),
akses = round(rnorm(n, 50, 10), 1)) # variabel eksklusi: hanya memengaruhi partisipasi
z1 <- as.numeric(scale(d$work_target_load))
z2 <- as.numeric(scale(d$hourly_wage))
za <- as.numeric(scale(d$akses))
rho <- runif(1, 0.3, 0.7) # korelasi galat seleksi dan galat outcome
u <- rnorm(n)
e <- rho * u + sqrt(1 - rho^2) * rnorm(n)
# persamaan seleksi (partisipasi)
g0 <- qnorm(runif(1, 0.55, 0.72))
d$partisipasi <- as.integer(g0 + runif(1, 0.4, 0.8) * z1 + runif(1, 0.1, 0.3) * z2 + runif(1, 0.6, 1) * za + u > 0)
# persamaan outcome (hanya teramati bila partisipasi = 1)
b1 <- runif(1, 0.25, 0.45); b2 <- runif(1, 0.08, 0.25) * sample(c(-1, 1), 1)
y_star <- 100 * (1 + b1 * z1 + b2 * z2 + 0.3 * e)
d$monthly_overtime_hours <- round(ifelse(d$partisipasi == 1, pmax(y_star, 0), 0), 3)
write.csv(d, "data_contoh.csv", row.names = FALSE)
# ---- Analisis 1: OLS naif dan Tobit (tersensor kiri di 0) ----
ols <- lm(monthly_overtime_hours ~ work_target_load + hourly_wage, data = d)
tob <- tobit(monthly_overtime_hours ~ work_target_load + hourly_wage, left = 0, data = d)
print(summary(ols)); print(summary(tob))
st <- coef(summary(tob))
sig_tob <- tob$scale
# ---- Analisis 2: Heckman dua tahap (heckit) dengan variabel eksklusi akses ----
hk <- selection(selection = partisipasi ~ work_target_load + hourly_wage + akses,
outcome = monthly_overtime_hours ~ work_target_load + hourly_wage, data = d, method = "2step")
print(summary(hk))
sh <- coef(summary(hk))
io <- hk$param$index$betaO # baris persamaan outcome
b_hk <- sh[io, ]; rownames(b_hk) <- c("(Intercept)", "work_target_load", "hourly_wage")
imr <- sh[hk$param$index$Mills, ] # koefisien inverse Mills ratio (lambda)
rho_hat <- unname(coef(hk)["rho"])
p_imr <- unname(imr[4])
nol <- 100 * mean(d$monthly_overtime_hours == 0)
cat(sprintf("Proporsi nol: %.1f%%, rho = %.3f, p IMR = %.4f\n", nol, rho_hat, p_imr))
# ---- Grafik ----
# 1) histogram Y dengan massa di nol
d$jenis <- factor(ifelse(d$monthly_overtime_hours == 0, "Zero (censored / not observed)", "Positive"),
levels = c("Zero (censored / not observed)", "Positive"))
p1 <- ggplot(d, aes(monthly_overtime_hours, fill = jenis)) +
geom_histogram(bins = 30, colour = warna$panel, alpha = 0.9) +
scale_fill_manual(values = c(pal[2], pal[1]), name = NULL) +
labs(title = sprintf("Distribution of monthly_overtime_hours (%.0f%% zeros)", 100 * mean(d$monthly_overtime_hours == 0)), x = "monthly_overtime_hours", y = "Count")
# 2) koefisien work_target_load: OLS vs Tobit vs Heckman (IK 95%)
dk <- data.frame(model = factor(c("OLS", "Tobit", "Heckman"), levels = c("Heckman", "Tobit", "OLS")),
b = c(coef(ols)["work_target_load"], st["work_target_load", 1], b_hk["work_target_load", 1]),
se = c(coef(summary(ols))["work_target_load", 2], st["work_target_load", 2], b_hk["work_target_load", 2]))
dk$teks <- sprintf("%.3f", dk$b)
p2 <- ggplot(dk, aes(b, model, colour = model)) +
geom_errorbarh(aes(xmin = b - 1.96 * se, xmax = b + 1.96 * se), height = 0.18, linewidth = 1) +
geom_point(size = 3.2) +
geom_text(aes(label = teks), vjust = -1.2, size = 3, colour = warna$teks) +
scale_colour_manual(values = c(OLS = pal[2], Tobit = pal[1], Heckman = pal[3]), guide = "none") +
scale_y_discrete(expand = expansion(add = 0.7)) +
labs(title = "Coefficient of work_target_load (95% CI)", x = "Estimate", y = NULL)
# 3) prediksi E[Y] menurut work_target_load (X2 di rata-rata)
xs <- seq(min(d$work_target_load), max(d$work_target_load), length.out = 100)
nd <- data.frame(work_target_load = xs, hourly_wage = mean(d$hourly_wage))
xb <- as.numeric(model.matrix(~ work_target_load + hourly_wage, nd) %*% coef(tob))
dp <- rbind(data.frame(x = xs, y = predict(ols, nd), model = "OLS"),
data.frame(x = xs, y = pnorm(xb / sig_tob) * xb + sig_tob * dnorm(xb / sig_tob), model = "Tobit E[Y]"),
data.frame(x = xs, y = as.numeric(model.matrix(~ work_target_load + hourly_wage, nd) %*% b_hk[, 1]), model = "Heckman E[Y*]"))
p3 <- ggplot() +
geom_point(data = d, aes(work_target_load, monthly_overtime_hours), colour = warna$redup, alpha = 0.3, size = 1.1) +
geom_line(data = dp, aes(x, y, colour = model), linewidth = 1.1) +
scale_colour_manual(values = c("OLS" = pal[2], "Tobit E[Y]" = pal[1], "Heckman E[Y*]" = pal[3]), name = NULL) +
labs(title = "Predicted monthly_overtime_hours by work_target_load", x = "work_target_load", y = "monthly_overtime_hours")
p_hasil <- if (tata == 1) p1 / (p2 | p3) else p1 | (p2 / p3)
print(p_hasil)
The original project file is available. It is not just the picture above: you get the working R project. It can be downloaded after payment, and we send it by WhatsApp or email.
ZIP: analisis.R + data_contoh.csv + BACA-DULU.txt
Choose how much help you need. Each higher package includes everything in the lower ones. Prices exclude 11% VAT.
Package 1
US$34
excl. 11% VAT
Duration: 7 working days
Output: R files + result figures
Deliverables
Package 2 · most chosen
US$100
excl. 11% VAT
Duration: 13 working days
Output: Code + analysis + interpretation notes
Includes all of Package 1, plus
Package 3
US$219
excl. 11% VAT
Duration: 18-21 working days
Output: Code + analysis + guidance until ready to present
Includes all of Packages 1 & 2, plus
Yes. The original project file is a ZIP containing the complete analisis.R script, a data_contoh.csv sample dataset and a BACA-DULU.txt guide. It can be downloaded after payment, and we send it by WhatsApp or email. For your own data (Package 2 and 3) the script is adapted to your dataset.
Yes. Tobit and Heckman Selection Models is commonly used at this level in Human Resource Management. We adapt the analysis to your research question, your own data and your supervisor's requirements.
No. The sheet is computed from illustrative synthetic data so you can see the kind of output R Studio gives. For your order we run the same method on your own data.
That is the point of the packages. Every script is commented, and Package 3 includes two coaching sessions plus practice questions so you can explain the method and the results at your seminar and defence.
Each project has three packages: Package 1 (code and explanation) US$34, Package 2 (your data analysis and interpretation) US$100 and Package 3 (full guidance) US$219, excluding 11% VAT. Larger datasets, extra methods or tight deadlines adjust the quote after a short consultation.
The result sheet uses illustrative synthetic data. R is a programming language of the R Foundation project; RStudio and Posit are trademarks of Posit PBC.
Back to R Studio portfolio