if (FALSE) {
library(sae.projection)
library(dplyr)
library(bonsai)
df_svy22_income <- df_svy22 %>% filter(!is.na(income))
df_svy23_income <- df_svy23 %>% filter(!is.na(income))
# Linear regression
lm_proj <- ma_projection(
income ~ age + sex + edu + disability,
cluster_ids = "PSU", weight = "WEIGHT", strata = "STRATA",
domain = c("PROV", "REGENCY"),
working_model = linear_reg(),
data_model = df_svy22_income,
data_proj = df_svy23_income,
nest = TRUE
)
df_svy22_neet <- df_svy22 %>% filter(between(age, 15, 24))
df_svy23_neet <- df_svy23 %>% filter(between(age, 15, 24))
# LightGBM regression with hyperparameter tunning
show_engines("boost_tree")
lgbm_model <- boost_tree(
mtry = tune(), trees = tune(), min_n = tune(),
tree_depth = tune(), learn_rate = tune(),
engine = "lightgbm"
)
lgbm_proj <- ma_projection(
formula = neet ~ sex + edu + disability,
cluster_ids = "PSU",
weight = "WEIGHT",
strata = "STRATA",
domain = c("PROV", "REGENCY"),
working_model = lgbm_model,
data_model = df_svy22_neet,
data_proj = df_svy23_neet,
cv_folds = 3,
tuning_grid = 3,
nest = TRUE
)
}
Run the code above in your browser using DataLab