# Load packages and scripts -------------------------------------------------------------------
source("manuscript/CICYPE/prep-workspace.R")
y_vars <- c("CM" = "comunicacion_total"
, "FM" = "motora_fina_total"
, "GM" = "motora_gruesa_total"
, "CG" = "resolucion_problemas_total"
, "PS" = "socio_individual_total")
many_models <- sapply(y_vars, function(i) {
form <- as.formula(
paste0(i, " ~ ",
"s(profesional_id, bs = \"re\") +
s(sexo_paciente, bs = \"re\") +
s(respondedor_vinculo, bs = \"re\") +",
"s(semanas_prematurez, k = 9)")
)
model <- gam(
form,
data = dataset,
method = "REML"
)
report_smooth(model)
}, simplify = FALSE)
tbl_data <- rbindlist(many_models, idcol = "Variable")
tbl_data <- tbl_data[term %like% "semanas_prematurez", list(Variable, Estadístico = expr)]
tbl <- knitr::kable(tbl_data, format = "simple")
saveRDS(tbl, file = "manuscript/CICYPE/resources/table-2.RDS")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.