Memuat
Memuat
Poisson Regression for Human Resource Management
0 views
Using synthetic data for illustration, this analysis aims to model the number of absence days and interpret incidence rate ratios. Poisson regression models count data (number of events per unit) with a log link, so predictor effects are read as incidence rate ratios. It suits theses on numbers of cases, claims, crashes or visits whose variance is roughly equal to the mean.

Using synthetic data for illustration, this analysis aims to model the number of absence days and interpret incidence rate ratios.
| Role | Variable | Unit |
|---|---|---|
| Main | Absence days | days |
| Supporting 1 | Commute distance | km |
| Supporting 2 | Monthly overtime | hours |
Each one-SD increase in Commute distance multiplies the expected Absence days by 1.394 (p < 0.001), while the IRR for Monthly overtime is 0.870. The model is significant (LR test p < 0.001). The deviance/df ratio of 0.97 supports the Poisson equidispersion assumption.
Computed from illustrative synthetic data, not from a real study.
Poisson regression models count data (number of events per unit) with a log link, so predictor effects are read as incidence rate ratios. It suits theses on numbers of cases, claims, crashes or visits whose variance is roughly equal to the mean.
An IRR above 1 means the event rate rises with the predictor and below 1 means it falls; report the IRR, 95% confidence interval and p-value. A deviance/df ratio well above 1 signals overdispersion, in which case a negative binomial model is more appropriate.
A short starting script with this project's variable names. The delivered version is adapted to your data and fully commented.
# Contoh kode R: Poisson Regression
suppressPackageStartupMessages({
library(ggplot2)
library(patchwork)
library(lmtest)
})
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 ----
n <- 200
d <- data.frame(commute_distance = rnorm(n, 50, 10),
monthly_overtime = rnorm(n, 30, 6))
z1 <- as.numeric(scale(d$commute_distance))
z2 <- as.numeric(scale(d$monthly_overtime))
mu0 <- runif(1, 2.5, 7) # rata-rata hitungan dasar
b1 <- runif(1, 0.25, 0.5)
b2 <- runif(1, 0.1, 0.3) * sample(c(-1, 1), 1)
d$absence_days <- rpois(n, mu0 * exp(b1 * z1 + b2 * z2)) # hitungan Poisson (tanpa overdispersi)
write.csv(d, "data_contoh.csv", row.names = FALSE)
# ---- Analisis: regresi Poisson (glm, family poisson, link log) ----
fit <- glm(absence_days ~ commute_distance + monthly_overtime, family = poisson, data = d)
s <- summary(fit)
print(s)
irr_tab <- exp(cbind(IRR = coef(fit), confint.default(fit))) # incidence rate ratio per satuan + CI 95%
print(round(irr_tab, 4))
# IRR per 1 simpangan baku prediktor (agar sebanding)
sdx <- c(sd(d$commute_distance), sd(d$monthly_overtime))
se_b <- s$coefficients[2:3, 2]
irr_sd <- data.frame(var = c("commute_distance", "monthly_overtime"),
irr = exp(coef(fit)[2:3] * sdx),
lo = exp((coef(fit)[2:3] - 1.96 * se_b) * sdx),
hi = exp((coef(fit)[2:3] + 1.96 * se_b) * sdx),
p = s$coefficients[2:3, 4])
print(irr_sd)
# ---- Uji model dan dispersi ----
fit0 <- glm(absence_days ~ 1, family = poisson, data = d)
lr <- lmtest::lrtest(fit0, fit) # uji likelihood ratio terhadap model null
print(lr)
p_lr <- lr[2, "Pr(>Chisq)"]
disp_dev <- fit$deviance / fit$df.residual # deviance/df: dekat 1 berarti tidak overdispersi
disp_pear <- sum(residuals(fit, type = "pearson")^2) / fit$df.residual
p_gof <- pchisq(fit$deviance, fit$df.residual, lower.tail = FALSE) # uji kecocokan deviance
r2_dev <- 1 - fit$deviance / fit$null.deviance
cat(sprintf("Deviance/df = %.3f; Pearson chi2/df = %.3f; GOF p = %.3f\n", disp_dev, disp_pear, p_gof))
# ---- Grafik ----
# Frekuensi teramati vs harapan model untuk tiap nilai hitungan
mu_hat <- fitted(fit)
k <- 0:max(d$absence_days)
dk <- data.frame(k = k,
teramati = as.numeric(table(factor(d$absence_days, levels = k))),
harapan = sapply(k, function(i) sum(dpois(i, mu_hat))))
p1 <- ggplot(dk, aes(k)) +
geom_col(aes(y = teramati, fill = "Observed"), alpha = 0.75, width = 0.8) +
geom_line(aes(y = harapan, colour = "Expected (Poisson)"), linewidth = 1) +
geom_point(aes(y = harapan, colour = "Expected (Poisson)"), size = 1.8) +
scale_fill_manual(values = c(Observed = pal[1]), name = NULL) +
scale_colour_manual(values = c("Expected (Poisson)" = pal[2]), name = NULL) +
labs(title = "Observed vs expected count frequencies", x = "absence_days", y = "Frequency")
# Laju prediksi menurut X1 (X2 pada rata-rata) dengan pita 95%
g <- data.frame(commute_distance = seq(min(d$commute_distance), max(d$commute_distance), length.out = 120), monthly_overtime = mean(d$monthly_overtime))
pr <- predict(fit, newdata = g, type = "link", se.fit = TRUE)
g$m <- exp(pr$fit); g$lo <- exp(pr$fit - 1.96 * pr$se.fit); g$hi <- exp(pr$fit + 1.96 * pr$se.fit)
p2 <- ggplot() +
geom_jitter(data = d, aes(commute_distance, absence_days), width = 0, height = 0.15, colour = pal[3], alpha = 0.45, size = 1.4) +
geom_ribbon(data = g, aes(commute_distance, ymin = lo, ymax = hi), fill = pal[2], alpha = 0.22) +
geom_line(data = g, aes(commute_distance, m), colour = pal[2], linewidth = 1.2) +
labs(title = "Predicted rate (95% CI)", x = "commute_distance", y = "absence_days")
p3 <- ggplot(irr_sd, aes(irr, var)) +
geom_vline(xintercept = 1, linetype = "dashed", colour = warna$redup) +
geom_segment(aes(x = lo, xend = hi, yend = var), colour = pal[1], linewidth = 1.1) +
geom_point(colour = pal[2], size = 3.2) +
geom_text(aes(label = sprintf("%.3f", irr)), vjust = -1.1, colour = warna$teks, size = 3.2) +
scale_x_log10() +
labs(title = "Incidence rate ratio per 1 SD (95% CI)", x = "IRR (log scale)", y = NULL)
p_hasil <- if (tata == 1) p1 / (p2 | p3) else (p1 / p3) | p2
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$25
excl. 11% VAT
Duration: 5 working days
Output: R files + result figures
Deliverables
Package 2 · most chosen
US$69
excl. 11% VAT
Duration: 9 working days
Output: Code + analysis + interpretation notes
Includes all of Package 1, plus
Package 3
US$153
excl. 11% VAT
Duration: 14-17 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. Poisson Regression 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$25, Package 2 (your data analysis and interpretation) US$69 and Package 3 (full guidance) US$153, 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