knitr::opts_chunk$set(warning = FALSE, message = FALSE)
pacman::p_load(tidyverse,
performance,
ggpubr)
theme_set(theme_minimal())
# datos felipe
df <- read_csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vQ4Nk96Jx1n-pLC1e7lXlUgMtqAFc1xOTyNCP6_72cvgtcZXjITM2-wocUbgKWin63eOHWZP3ezwJoB/pub?gid=1163641714&single=true&output=csv")
# datos que yo tenÃa
# df <- read_csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vQ4Nk96Jx1n-pLC1e7lXlUgMtqAFc1xOTyNCP6_72cvgtcZXjITM2-wocUbgKWin63eOHWZP3ezwJoB/pub?gid=1163641714&single=true&output=csv")
head(df)
Convert colutorio to factor
df <- df %>%
mutate(Colutorio = as.factor(Colutorio))
glimpse(df)
## Rows: 273
## Columns: 4
## $ ID <dbl> 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, …
## $ Colutorio <fct> 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, …
## $ Tiempo <chr> "T0", "T1", "T2", "T3", "T4", "T5", "T6", "T0", "T1", "T2", …
## $ Reduccion <dbl> 100.0, 43.9, 63.4, 71.4, 85.6, 71.8, 73.9, 100.0, 55.4, 50.0…
df %>%
# pivot_longer(Colutorio:Tiempo,
# names_to = "Variables",
# values_to = "Values") %>%
ggplot(aes(x = Reduccion)) +
geom_histogram() +
facet_grid(Tiempo ~ Colutorio)
df %>%
select(-ID) %>%
gtsummary::tbl_summary(by = Colutorio)
Characteristic | 96, N = 771 | 97, N = 981 | 98, N = 981 |
---|---|---|---|
Tiempo | |||
T0 | 11 (14%) | 14 (14%) | 14 (14%) |
T1 | 11 (14%) | 14 (14%) | 14 (14%) |
T2 | 11 (14%) | 14 (14%) | 14 (14%) |
T3 | 11 (14%) | 14 (14%) | 14 (14%) |
T4 | 11 (14%) | 14 (14%) | 14 (14%) |
T5 | 11 (14%) | 14 (14%) | 14 (14%) |
T6 | 11 (14%) | 14 (14%) | 14 (14%) |
Reduccion | 93 (82, 100) | 70 (53, 89) | 89 (70, 100) |
1
n (%); Median (IQR)
|
df %>%
ggplot(aes(x = Tiempo,
y = Reduccion,
fill = Colutorio)) +
geom_violin(draw_quantiles = 0.5)
df %>%
ggline(x = "Tiempo",
y = "Reduccion",
color = "Colutorio",
add = c("mean_se", "dotplot")) +
labs(title = "Profile plot de reducción en tiempo y por tipo de colutorio") +
theme_pubr()
a2w <- aov(Reduccion ~ Tiempo + Colutorio + Tiempo*Colutorio ,
data = df)
summary(a2w)
## Df Sum Sq Mean Sq F value Pr(>F)
## Tiempo 6 27338 4556 15.276 6.4e-15 ***
## Colutorio 2 29277 14639 49.078 < 2e-16 ***
## Tiempo:Colutorio 12 10037 836 2.804 0.00129 **
## Residuals 252 75164 298
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
df %>%
with(aov(Reduccion ~ Tiempo + Colutorio + Tiempo:Colutorio + Error(ID))) %>%
summary()
##
## Error: ID
## Df Sum Sq Mean Sq
## Colutorio 1 254.8 254.8
##
## Error: Within
## Df Sum Sq Mean Sq F value Pr(>F)
## Tiempo 6 27338 4556 15.221 7.33e-15 ***
## Colutorio 2 29050 14525 48.522 < 2e-16 ***
## Tiempo:Colutorio 12 10037 836 2.794 0.00134 **
## Residuals 251 75136 299
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
performance::check_model(a2w)
performance::model_performance(a2w)
Eliminar el interpecto por cada medicion
a2w_sinID <- aov(Reduccion ~ Tiempo + Colutorio + Tiempo:Colutorio,
data = df)
summary(a2w_sinID)
## Df Sum Sq Mean Sq F value Pr(>F)
## Tiempo 6 27338 4556 15.276 6.4e-15 ***
## Colutorio 2 29277 14639 49.078 < 2e-16 ***
## Tiempo:Colutorio 12 10037 836 2.804 0.00129 **
## Residuals 252 75164 298
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
performance::compare_performance(a2w, a2w_sinID)
son iguales
a2w_3 <- lm(Reduccion ~ Tiempo:Colutorio,
data = df)
summary(a2w_3)
##
## Call:
## lm(formula = Reduccion ~ Tiempo:Colutorio, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -59.429 -10.086 0.000 8.014 77.800
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 95.8143 4.6157 20.758 < 2e-16 ***
## TiempoT0:Colutorio96 4.1857 6.9585 0.602 0.548030
## TiempoT1:Colutorio96 -4.1870 6.9585 -0.602 0.547906
## TiempoT2:Colutorio96 -4.7688 6.9585 -0.685 0.493768
## TiempoT3:Colutorio96 -2.9143 6.9585 -0.419 0.675711
## TiempoT4:Colutorio96 -0.3779 6.9585 -0.054 0.956730
## TiempoT5:Colutorio96 0.9675 6.9585 0.139 0.889527
## TiempoT6:Colutorio96 0.2312 6.9585 0.033 0.973525
## TiempoT0:Colutorio97 4.1857 6.5276 0.641 0.521956
## TiempoT1:Colutorio97 -41.7429 6.5276 -6.395 7.75e-10 ***
## TiempoT2:Colutorio97 -39.5929 6.5276 -6.065 4.79e-09 ***
## TiempoT3:Colutorio97 -33.8500 6.5276 -5.186 4.42e-07 ***
## TiempoT4:Colutorio97 -33.7000 6.5276 -5.163 4.94e-07 ***
## TiempoT5:Colutorio97 -24.7714 6.5276 -3.795 0.000185 ***
## TiempoT6:Colutorio97 -11.8286 6.5276 -1.812 0.071164 .
## TiempoT0:Colutorio98 4.1857 6.5276 0.641 0.521956
## TiempoT1:Colutorio98 -29.1643 6.5276 -4.468 1.19e-05 ***
## TiempoT2:Colutorio98 -22.6429 6.5276 -3.469 0.000615 ***
## TiempoT3:Colutorio98 -9.2857 6.5276 -1.423 0.156111
## TiempoT4:Colutorio98 -2.9286 6.5276 -0.449 0.654075
## TiempoT5:Colutorio98 -0.5500 6.5276 -0.084 0.932919
## TiempoT6:Colutorio98 NA NA NA NA
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 17.27 on 252 degrees of freedom
## Multiple R-squared: 0.47, Adjusted R-squared: 0.4279
## F-statistic: 11.17 on 20 and 252 DF, p-value: < 2.2e-16
performance::compare_performance(a2w, a2w_3)
performance::test_performance(a2w, a2w_3)