library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.3 ✓ purrr 0.3.4
## ✓ tibble 3.1.0 ✓ dplyr 1.0.5
## ✓ tidyr 1.1.3 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(here)
## here() starts at /cloud/project
JuanModel <-
"est_apre_act =~ i1 + i2 + i3 + i4 + i5
mot_intri =~ i6 + i7 + i8 + i9 + i10
desemp =~ i11 + i12 + i13
desemp =~ est_apre_act+mot_intri"
JuanSimData <- read_csv(here("SEM lavaan/data_sem", "juan.csv"))
##
## ── Column specification ────────────────────────────────────────────────────────
## cols(
## i1 = col_double(),
## i2 = col_double(),
## i3 = col_double(),
## i4 = col_double(),
## i5 = col_double(),
## i6 = col_double(),
## i7 = col_double(),
## i8 = col_double(),
## i9 = col_double(),
## i10 = col_double(),
## i11 = col_double(),
## i12 = col_double(),
## i13 = col_double(),
## genero = col_character()
## )
Programa: 13 Ingenierías Edad: 16 - 30 Estado civil, estrato socioeconómico 1 - 6 (4) ingresos familiares: categorías? 5 opciones 1 más bajo y 5 más alto depende económicamente: si/no nivel educativo padre: opciones (1 a 4) 1 es la menor nivel educativo madre: opciones (1 a 4) 1 es la menor
juan_LM <-
JuanSimData %>%
rowwise() %>%
mutate(est_apre_act = mean(c(i1, i2, i3,i4, i5)),
mot_intri = mean(c(i6, i7, i8, i9, i10)),
desemp = mean(c(i11, i12, i13))) %>%
select(est_apre_act, mot_intri, desemp, genero)
head(juan_LM)
juan_LM %>%
keep(is.numeric) %>%
gather() %>%
ggplot(aes(value)) +
facet_wrap(~ key, scales = "free") +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Construimos el modelo
juan_model_LM <-
lm(desemp ~ est_apre_act + mot_intri,
data = juan_LM)
Revisamos el modelo
summary(juan_model_LM)
##
## Call:
## lm(formula = desemp ~ est_apre_act + mot_intri, data = juan_LM)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.65430 -0.32071 0.01237 0.32305 1.55516
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.57974 0.06146 9.432 <2e-16 ***
## est_apre_act 0.38899 0.01871 20.793 <2e-16 ***
## mot_intri 0.38771 0.01935 20.040 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4749 on 1997 degrees of freedom
## Multiple R-squared: 0.4262, Adjusted R-squared: 0.4256
## F-statistic: 741.5 on 2 and 1997 DF, p-value: < 2.2e-16
Que por cada unidad incrementada en est_apre_act el desempeño aumentará en un 0.38 unidades.