#' Rescale O-NET skills
#'
#' This function adjusts the skills data. Some skills were valued by job incumbents, others by occupational experts/analysts. As job incumbents are
#' likely to systematically over-value skill level/importance, the raw skill measures in O-NET are adjusted to account for this. Each skill level
#' and importance measure is regressed on occupation fixed effects, year fixed effects, and a dummy variable indicating if the occupation was
#' rate by job incumbents. The value of this coefficient is subtracted from the skill measure reported by job incumbents.
#'
#' @param p3
#' - The object produced by `phase3_onet()`
#'
#' @return A list two dataframes of panels for each of the O-NET domains
#' - `skill`
#' - `skill.raw`
#'
#' @export
rescale_skills <- function(p3=NULL) {
skill.raw <- data.frame(p3[["skills.cleaned"]]) %>%
dplyr::mutate(Incumbent = if_else(Incumbent==0,0,1))
skill <- data.frame(p3[["skills.cleaned"]]) %>%
dplyr::mutate(Incumbent = if_else(Incumbent==0,0,1))
# LOOP OVER ALL SKILLS
for (i in 5:74) {
j <- i - 4
#print(paste0("Phase 4 of 6: Now Running Skill Regression ",j," of ",70))
skill$depvar <- skill[,i]
# fixed effects regression on incumbent dummy, year dummies
model <- plm(depvar ~ Incumbent + as.factor(year),
data=skill,
na.action = na.omit,
index = c("onetsoc2010code","year"),
model="within")
# subtract the incumbent effect from the data value
skill[,i] <- skill[,i] - skill[,"Incumbent"]*coef(model)["Incumbent"]
}
skill <- skill[,c(1:74)]
return.list <- list(skill=skill,
skill.raw=skill.raw)
return(return.list)
}
#' Rescale O-NET abilities
#'
#' This function adjusts the abilities data. Some abilities were valued by job incumbents, others by occupational experts/analysts. As job incumbents are
#' likely to systematically over-value ability level/importance, the raw skill measures in O-NET are adjusted to account for this. Each abilities level
#' and importance measure is regressed on occupation fixed effects, year fixed effects, and a dummy variable indicating if the occupation was
#' rate by job incumbents. The value of this coefficient is subtracted from the abilities measure reported by job incumbents.
#'
#' @param p3
#' - The object produced by `phase3_onet()`
#'
#' @return A list two dataframes of panels for each of the O-NET domains
#' - `abilities`
#' - `abilities.raw`
#'
#' @export
rescale_abilities <- function(p3=NULL) {
# No incumbent ratings for abilities
abilities.raw <- data.frame(p3[["abilities.cleaned"]]) %>%
dplyr::mutate(Incumbent = if_else(Incumbent==0,0,1))
abilities <- data.frame(p3[["abilities.cleaned"]]) %>%
dplyr::mutate(Incumbent = if_else(Incumbent==0,0,1))
return.list <- list(abilities=abilities,
abilities.raw=abilities.raw)
return(return.list)
}
#' Rescale O-NET activities
#'
#' This function adjusts the activities data. Some activities were valued by job incumbents, others by occupational experts/analysts. Each activities level
#' and importance measure is regressed on occupation fixed effects, year fixed effects, and a dummy variable indicating if the occupation was
#' rate by job incumbents. The value of this coefficient is subtracted from the activities measure reported by job incumbents.
#'
#' @param p3
#' - The object produced by `phase3_onet()`
#'
#' @return A list two dataframes of panels for each of the O-NET domains
#' - `activities`
#' - `activities.raw`
#'
#' @export
rescale_activities <- function(p3=NULL) {
activities.raw <- data.frame(p3[["activities.cleaned"]]) %>%
dplyr::mutate(Incumbent = if_else(Incumbent==0,0,1))
activities <- data.frame(p3[["activities.cleaned"]]) %>%
dplyr::mutate(Incumbent = if_else(Incumbent==0,0,1))
# LOOP OVER ALL ACTIVITIES
for (i in 5:86) {
j <- i - 4
#print(paste0("Phase 4 of 6: Now Running Work Activity Regression ",j," of ",82))
activities$depvar <- activities[,i]
# fixed effects regression on incumbent dummy, year dummies
model <- plm(depvar ~ Incumbent + as.factor(year),
data=activities,
na.action = na.omit,
index = c("onetsoc2010code","year"),
model="within")
# subtract the incumbent effect from the data value
activities[,i] <- activities[,i] - activities[,"Incumbent"]*coef(model)["Incumbent"]
}
activities <- activities[,c(1:86)]
return.list <- list(activities=activities,
activities.raw=activities.raw)
return(return.list)
}
#' Rescale O-NET work contexts
#'
#' This function adjusts the skills data. Some skills were valued by job incumbents, others by occupational experts/analysts. As job incumbents are
#' likely to systematically over-value skill level/importance, the raw skill measures in O-NET are adjusted to account for this. Each skill level
#' and importance measure is regressed on occupation fixed effects, year fixed effects, and a dummy variable indicating if the occupation was
#' rate by job incumbents. The value of this coefficient is subtracted from the skill measure reported by job incumbents.
#'
#' @param p3
#' - The object produced by `phase3_onet()`
#'
#' @return A list two dataframes of panels for each of the O-NET domains
#' - `context`
#' - `context.raw`
#'
#' @export
rescale_contexts <- function(p3=NULL) {
context.raw <- data.frame(p3[["contexts.cleaned"]]) %>%
dplyr::mutate(Incumbent = if_else(Incumbent==0,0,1))
context <- data.frame(p3[["contexts.cleaned"]]) %>%
dplyr::mutate(Incumbent = if_else(Incumbent==0,0,1))
# LOOP OVER ALL CONTEXTS
for (i in 5:59) {
context$depvar <- context[,i]
# fixed effects regression on incumbent dummy, year dummies
model <- plm(depvar ~ Incumbent + as.factor(year),
data=context,
na.action = na.omit,
index = c("onetsoc2010code","year"),
model="within")
# subtract the incumbent effect from the data value
context[,i] <- context[,i] - context[,"Incumbent"]*coef(model)["Incumbent"]
}
context <- context[,c(1:59)]
return.list <- list(context=context,
context.raw=context.raw)
return(return.list)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.