| nlswork_subset | R Documentation |
A subset of 300 randomly sampled women from the National Longitudinal Survey of Young Women, 1968-1988. This is a subsample of the full nlswork dataset commonly used in Stata examples. The data contains labor market information for young women tracked over multiple years.
nlswork_subset
A data frame with approximately 2,400-2,700 observations (depending on sampling) and the following variables:
Individual identifier (numeric)
Survey year (numeric)
Year of birth (numeric)
Age in current year (numeric)
Race: 1=white, 2=black, 3=other (numeric or labeled)
Marital status: 1=never married, 2=married, 3=separated/divorced/widowed (numeric or labeled)
1 if never married (numeric)
Current grade completed (numeric)
1 if college graduate (numeric)
1 if not in SMSA (Standard Metropolitan Statistical Area) (numeric)
1 if in central city (numeric)
1 if in south (numeric)
Industry code (numeric)
Occupation code (numeric)
1 if union member (numeric)
Weeks unemployed last year (numeric)
Total work experience (years) (numeric)
Job tenure in years (numeric)
Usual hours worked per week (numeric)
Weeks worked last year (numeric)
Natural log of hourly wage (numeric)
This dataset is a subset of the nlswork data available from Stata Press. It contains 300 randomly sampled individuals from the original 5,159 women, preserving all time periods for the selected individuals. The data is an unbalanced panel with varying numbers of observations per individual.
The subset was created using:
set.seed(123) unique_ids <- unique(nlswork$idcode) sampled_ids <- sample(unique_ids, size = 300, replace = FALSE) nlswork_subset <- nlswork[nlswork$idcode %in% sampled_ids, ]
Original data from Stata Press: https://www.stata-press.com/data/r19/nlswork.dta
National Longitudinal Survey of Young Women, 1968-1988. U.S. Bureau of Labor Statistics.
Center for Human Resource Research. (2002). NLS Handbook 2001. Columbus, OH: The Ohio State University.
# Load the data
data(nlswork_subset)
# Examine structure
str(nlswork_subset)
# Summary statistics
summary(nlswork_subset$ln_wage)
# Panel structure
table(table(nlswork_subset$idcode)) # Distribution of obs per individual
## Not run:
# Example analysis with xtvfreg
# Create race groups
nlswork_subset$race_group <- factor(nlswork_subset$race,
levels = 1:2,
labels = c("white", "black"))
# Create within and between components for tenure
nlswork_subset$m_tenure <- ave(nlswork_subset$tenure,
nlswork_subset$idcode,
FUN = function(x) mean(x, na.rm = TRUE))
nlswork_subset$d_tenure <- nlswork_subset$tenure - nlswork_subset$m_tenure
# Estimate varying effects model
result <- xtvfreg(
formula = ln_wage ~ 1,
data = subset(nlswork_subset, !is.na(ln_wage) & race %in% 1:2),
group = "race_group",
panel_id = "idcode",
mean_vars = c("m_tenure", "d_tenure", "age"),
var_vars = c("m_tenure", "age"),
verbose = TRUE
)
# View results
summary(result)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.