data("occup_small", package = "cat2cat")
data("trans", package = "cat2cat")
occup_old <- occup_small[occup_small$year == 2008, ]
occup_new <- occup_small[occup_small$year == 2010, ]
occup_2 <- cat2cat(
data = list(
old = occup_old,
new = occup_new,
cat_var = "code",
time_var = "year"
),
mappings = list(trans = trans, direction = "backward"),
ml = list(
data = occup_new,
cat_var = "code",
method = "knn",
features = c("age", "sex", "edu", "exp", "parttime", "salary"),
args = list(k = 10)
)
)
# Regression
# we have to adjust size of std as we artificialy enlarge degrees of freedom
lms <- lm(
formula = I(log(salary)) ~ age + sex + factor(edu) + parttime + exp,
data = occup_2$old,
weights = multiplier * wei_freq_c2c
)
summary_c2c(lms, df_old = nrow(occup_old))
Run the code above in your browser using DataLab