library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 1.0.0
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(datarium)
jobsatisfaction
library(dlookr)
##
## Attaching package: 'dlookr'
## The following object is masked from 'package:tidyr':
##
## extract
## The following object is masked from 'package:base':
##
## transform
library(gtsummary)
jobsatisfaction %>% group_by(gender, education_level) %>% describe(score)
Comprobar la normalidad (el supuesto de normal)
jobsatisfaction %>% group_by(gender, education_level) %>% normality(score)
jobsatisfaction %>% group_by(gender, education_level) %>% plot_normality(score)
calculo de varianza
PRUEBA DE LEVENE
Cuando p < 0.05 = NO SE ASUME IGUALDAD EN VARIANZAS
Cuando p > 0.05 = SE AS IGUALDAD EN VARIANZAS
La prueba de levene fue no significativa (p = 0.06 ) Podemos asumir que la homeneidad es igual
jobsatisfaction %>% rstatix::levene_test(score ~ gender*education_level)
Visualización de los datos con gráficas
library(ggpubr)
bxp <- ggboxplot(jobsatisfaction, x="gender", y="score",
fill= "education_level" , palette = "Paired")
bxp
Paletas de colores
valores atípicos (outliers)
con función: identify_outliers
jobsatisfaction %>% group_by(gender, education_level) %>% rstatix::identify_outliers(score)
la función para anova es: aov o también:
anova_test
res.aov<-jobsatisfaction %>% rstatix::anova_test(score ~ gender*education_level)
res.aov
Si se encontró una interacción estadísticamente significativa entre género y el nivel de educación para la puntuación (score) de satisfacción laboral (p = 0.002)
Se trabajar con el paquete: emmeans
#install.packages("emmeans")
library(emmeans)
library(rstatix)
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
library(gt)
cm <-jobsatisfaction %>% group_by(gender) %>% emmeans_test(score ~ education_level, p.adjust.method =)
jobsatisfaction %>% group_by(gender) %>% emmeans_test(score ~ education_level) %>% gt()
| gender | term | .y. | group1 | group2 | df | statistic | p | p.adj | p.adj.signif |
|---|---|---|---|---|---|---|---|---|---|
| female | education_level | score | school | college | 52 | -2.935226 | 4.952503e-03 | 1.485751e-02 | * |
| female | education_level | score | school | university | 52 | -10.834318 | 6.074300e-15 | 1.822290e-14 | **** |
| female | education_level | score | college | university | 52 | -7.899092 | 1.838428e-10 | 5.515284e-10 | **** |
| male | education_level | score | school | college | 52 | -3.072573 | 3.374111e-03 | 1.012233e-02 | * |
| male | education_level | score | school | university | 52 | -15.295045 | 6.865425e-21 | 2.059628e-20 | **** |
| male | education_level | score | college | university | 52 | -12.142652 | 8.421634e-17 | 2.526490e-16 | **** |
Visualización de valores p del análisis post hoc en la grafica boxplot