knitr::opts_chunk$set(collapse = TRUE, comment = "#>", dpi = 300) options(width = 140)
Note: As a priority, this analyses were run using only those with a diagnosis of congenital hypotonia.
Setup details
library(ASQ3) library(data.table) dataset <- dataset[diagnostico %like% "hipotonia"]
For this page, we'll be fitting different models using generalized additive models (GAM's) using the mgcv
package for modeling non-linear relationships, even though it can be used to model linear relationships too. The smoothing parameter (the one that gets to decide how wiggly will be the curve) will be estimated using restricted maximum likelihood (i.e., REML).
The interpretation of the summary of GAM models in R can be seen in this short video (~ 4 minutes) from datacamp. However, let's get a short intro to a fast interpretation!
Approximate significance of smooth terms: edf Ref.df F p-value s(edad_cronologica_meses) 6.475 7.561 28.98 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
This small part of a summary output shows that the influence of edad_cronologica_meses
is significant at a p-value of <2e-16. The edf
stands for "Effective Degrees of Freedom" and reflects how complex (or wiggly) the relationship is. Thus, an edf
of 1 reflects a linear relationship, while and edf
of 2 reflects a cuadratic relationship, an edf
of 3 cubic relationship and so on.
More information about GAMs can be seen here:
Model: comunicacion_total ~ edad_cronologica_meses
plot_gam(data = dataset[n_evaluacion == 1 & edad_cronologica_meses <= 60], x = edad_cronologica_meses, y = comunicacion_total, ylab = "Communication", xlab = "Months old", round_to = 5, method = "REML") library(mgcv) mgcv::gam(formula = comunicacion_total ~ s(edad_cronologica_meses), data = dataset[n_evaluacion == 1 & edad_cronologica_meses <= 60], method = "REML") |> summary()
Model: resolucion_problemas_total ~ edad_cronologica_meses
plot_gam(data = dataset[n_evaluacion == 1 & edad_cronologica_meses <= 60], x = edad_cronologica_meses, y = resolucion_problemas_total, ylab = "Problem solving", xlab = "Months old", round_to = 5, method = "REML") mgcv::gam(formula = resolucion_problemas_total ~ s(edad_cronologica_meses), data = dataset[n_evaluacion == 1 & edad_cronologica_meses <= 60], method = "REML") |> summary()
Model: comunicacion_total ~ edad_corregida_meses
plot_gam(data = dataset[n_evaluacion == 1 & edad_corregida_meses <= 60], x = edad_corregida_meses, y = comunicacion_total, ylab = "Communication", xlab = "Corrected age (months old)", round_to = 5, method = "REML") mgcv::gam(formula = comunicacion_total ~ s(edad_corregida_meses), data = dataset[n_evaluacion == 1 & edad_corregida_meses <= 60], method = "REML") |> summary()
Model: motora_fina_total ~ edad_corregida_meses
plot_gam(data = dataset[n_evaluacion == 1 & edad_corregida_meses <= 60], x = edad_corregida_meses, y = motora_fina_total, ylab = "Fine motor skills", xlab = "Corrected age (months old)", round_to = 5, method = "REML") mgcv::gam(formula = motora_fina_total ~ s(edad_corregida_meses), data = dataset[n_evaluacion == 1 & edad_corregida_meses <= 60], method = "REML") |> summary()
Model: resolucion_problemas_total ~ edad_corregida_meses
plot_gam(data = dataset[n_evaluacion == 1 & edad_corregida_meses <= 60], x = edad_corregida_meses, y = resolucion_problemas_total, ylab = "Fine motor skills", xlab = "Corrected age (months old)", round_to = 5, method = "REML") mgcv::gam(formula = resolucion_problemas_total ~ s(edad_corregida_meses), data = dataset[n_evaluacion == 1 & edad_corregida_meses <= 60], method = "REML") |> summary()
Model: socio_individual_total ~ edad_corregida_meses
plot_gam(data = dataset[n_evaluacion == 1 & edad_corregida_meses <= 60], x = edad_corregida_meses, y = socio_individual_total, ylab = "Socio-individual skills", xlab = "Corrected age (months old)", round_to = 4, method = "REML") mgcv::gam(formula = socio_individual_total ~ s(edad_corregida_meses), data = dataset[n_evaluacion == 1 & edad_corregida_meses <= 60], method = "REML") |> summary()
Model: comunicacion_total ~ asq3_meses
plot_gam(data = dataset[n_evaluacion == 1], x = asq3_meses, y = comunicacion_total, ylab = "Communication", xlab = "developmental ASQ-3 age (months old)", round_to = 5, method = "REML") mgcv::gam(formula = comunicacion_total ~ s(asq3_meses), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Model: resolucion_problemas_total ~ asq3_meses
plot_gam(data = dataset[n_evaluacion == 1], x = asq3_meses, y = resolucion_problemas_total, ylab = "Problem solving", xlab = "developmental ASQ-3 age (months old)", round_to = 5, method = "REML") mgcv::gam(formula = resolucion_problemas_total ~ s(asq3_meses), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Model: motora_fina_total ~ asq3_meses
plot_gam(data = dataset[n_evaluacion == 1], x = asq3_meses, y = motora_fina_total, ylab = "Fine motor skills", xlab = "developmental ASQ-3 age (months old)", round_to = 5, method = "REML") mgcv::gam(formula = motora_fina_total ~ s(asq3_meses), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Model: motora_fina_total ~ comunicacion_total
plot_gam(data = dataset[n_evaluacion == 1], x = comunicacion_total, y = motora_fina_total, ylab = "Fine motor skills", xlab = "Communication", round_to = 5, method = "REML") mgcv::gam(formula = motora_fina_total ~ s(comunicacion_total), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Model: socio_individual_total ~ comunicacion_total
plot_gam(data = dataset[n_evaluacion == 1], x = comunicacion_total, y = socio_individual_total, ylab = "Socio-individual skills", xlab = "Communication", round_to = 5, method = "REML") mgcv::gam(formula = socio_individual_total ~ s(comunicacion_total), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Model: motora_gruesa_total ~ comunicacion_total
plot_gam(data = dataset[n_evaluacion == 1], x = comunicacion_total, y = motora_gruesa_total, ylab = "Gross motor skills", xlab = "Communication", round_to = 5, method = "REML") mgcv::gam(formula = motora_gruesa_total ~ s(comunicacion_total), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Looks more like a linear relationship than a non-linear one. This is notorious when we look at the effective degrees of freedom (edf), i.e. the closer to 1 more alike to a linear regression. Although is not significant at a 5% level.
Model: resolucion_problemas_total ~ motora_fina_total
plot_gam(data = dataset[n_evaluacion == 1], x = motora_fina_total, y = resolucion_problemas_total, ylab = "Problem solving", xlab = "Fine motor skills", round_to = 5, method = "REML") mgcv::gam(formula = resolucion_problemas_total ~ s(motora_fina_total), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Model: socio_individual_total ~ motora_fina_total
plot_gam(data = dataset[n_evaluacion == 1], x = motora_fina_total, y = socio_individual_total, ylab = "Socio-individual skills", xlab = "Fine motor skills", round_to = 5, method = "REML") mgcv::gam(formula = socio_individual_total ~ s(motora_fina_total), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Model: resolucion_problemas_total ~ comunicacion_total
plot_gam(data = dataset[n_evaluacion == 1], x = comunicacion_total, y = resolucion_problemas_total, ylab = "Problem solving", xlab = "Communication", round_to = 5, method = "REML") mgcv::gam(formula = resolucion_problemas_total ~ s(comunicacion_total), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Model: resolucion_problemas_total ~ motora_gruesa_total
plot_gam(data = dataset[n_evaluacion == 1], x = motora_gruesa_total, y = resolucion_problemas_total, ylab = "Problem solving", xlab = "Gross motor skills", round_to = 5, method = "REML") mgcv::gam(formula = resolucion_problemas_total ~ s(motora_gruesa_total), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
Model: resolucion_problemas_total ~ socio_individual_total
plot_gam(data = dataset[n_evaluacion == 1], x = socio_individual_total, y = resolucion_problemas_total, ylab = "Problem solving", xlab = "Socio-individual skills", round_to = 5, method = "REML") mgcv::gam(formula = resolucion_problemas_total ~ s(socio_individual_total), data = dataset[n_evaluacion == 1], method = "REML") |> summary()
unadjusted <- mgcv::gam(formula = comunicacion_total ~ s(edad_cronologica_meses), data = dataset[n_evaluacion == 1], method = "REML") adjusted <- mgcv::gam(formula = comunicacion_total ~ profesional_id + s(edad_cronologica_meses), data = dataset[n_evaluacion == 1], method = "REML") summary(unadjusted) summary(adjusted) anova(unadjusted, adjusted, test = "Chisq") par(mfrow = c(1,2)) plot(unadjusted, shade = TRUE, xlab = "Edad cronológica", ylab = "Efecto en Habilidades comunicativas", seWithMean = TRUE, main = "Sin ajuste", ylim = c(-25, 15)) abline(h = c(0,-15)) plot(adjusted, shade = TRUE, xlab = "Edad cronológica", ylab = "Efecto en Habilidades comunicativas", seWithMean = TRUE, main = "Ajustando por el evaluador", ylim = c(-25, 15)) abline(h = c(0,-15))
unadjusted <- mgcv::gam(formula = comunicacion_total ~ s(edad_corregida_meses), data = dataset[n_evaluacion == 1], method = "REML") adjusted <- mgcv::gam(formula = comunicacion_total ~ profesional_id + s(edad_corregida_meses), data = dataset[n_evaluacion == 1], method = "REML") summary(unadjusted) summary(adjusted) anova(unadjusted, adjusted, test = "Chisq") par(mfrow = c(1,3)) plot(unadjusted, shade = TRUE, xlab = "Edad corregida", ylab = "Efecto en Habilidades comunicativas", seWithMean = TRUE, main = "Sin ajuste", ylim = c(-25, 15)) abline(h = c(0,-15)) plot(adjusted, shade = TRUE, xlab = "Edad corregida", ylab = "Efecto en Habilidades comunicativas", seWithMean = TRUE, main = "Ajustando por el evaluador", ylim = c(-25, 15)) plot(adjusted, all.terms = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.