library(tidyverse)
library(here)
library(performance)
library(lme4)
Loading required package: Matrix
Attaching package: ‘Matrix’
The following objects are masked from ‘package:tidyr’:
expand, pack, unpack
Registered S3 methods overwritten by 'lme4':
method from
cooks.distance.influence.merMod car
influence.merMod car
dfbeta.influence.merMod car
dfbetas.influence.merMod car
library(glmmTMB)
library(see)
library(ggrepel)
library(qqplotr)
LuisModel <-
"dis_ped =~ i1 + i2 +i3
prac_ped =~ i4 + i5 + i6
gest_aula =~ i7 + i8 + i9
segu_acad =~ i10 + i11 + i12 + i13 + i14
prom_estu =~ i15 + i16 + i17 + i18 + i19
rend_aca =~ i20
gest_aca =~ dis_ped + prac_ped + gest_aula + segu_acad
rend_aca =~ gest_aca + prom_estu
"
luis_raw <- read_csv(here("SEM lavaan/data_sem", "luis_lm.csv"))
── Column specification ────────────────────────────────────────────────────────────────────────────────────
cols(
.default = col_double(),
genero = col_character()
)
ℹ Use `spec()` for the full column specifications.
luis_LM <-
luis_raw %>%
rowwise() %>%
mutate(dis_ped = mean(c(i1, i2, i3)),
prac_ped = mean(c(i4, i5, i6)),
gest_aula = mean(c(i7, i8, i9)),
segu_acad = mean(c(i10, i11, i12, i13, i14)),
com_ev_pro = mean(c(i15, i16, i17, i18, i19)),
rend_aca = i20) %>%
select(gest_aca, dis_ped, prac_ped, gest_aula, segu_acad, genero)
Note: Using an external vector in selections is ambiguous.
ℹ Use `all_of(gest_aca)` instead of `gest_aca` to silence this message.
ℹ See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
This message is displayed once per session.
Error: Must subset columns with a valid subscript vector.
x Subscript has the wrong type `formula`.
ℹ It must be numeric or character.
Run `rlang::last_error()` to see where the error occurred.
Construimos el modelo
luis_model_LM <-
lm(gest_aca ~ dis_ped + prac_ped + gest_aula + segu_acad + prom_estu + genero + institucion,
data = luis_LM)
Error in model.frame.default(formula = gest_aca ~ dis_ped + prac_ped + :
object is not a matrix
Revisamos el modelo
summary(luis_model_LM)
Call:
lm(formula = rend_aca ~ dis_ped + prac_ped + gest_aula + segu_acad +
prom_estu + genero + institucion, data = luis_LM)
Residuals:
Min 1Q Median 3Q Max
-41.398 -9.768 -0.276 8.836 51.207
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -5.73287 7.14839 -0.802 0.4230
dis_ped 4.83234 1.05952 4.561 6.44e-06 ***
prac_ped 6.28219 1.10727 5.674 2.39e-08 ***
gest_aula 4.94248 1.02666 4.814 1.97e-06 ***
segu_acad 2.40412 1.14881 2.093 0.0369 *
prom_estu 1.40404 0.93088 1.508 0.1321
generom 0.28721 1.43543 0.200 0.8415
institucion 0.03078 0.17262 0.178 0.8586
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 14.61 on 492 degrees of freedom
Multiple R-squared: 0.2896, Adjusted R-squared: 0.2795
F-statistic: 28.66 on 7 and 492 DF, p-value: < 2.2e-16
Que por cada unidad incrementada en segu_acad el desempeño aumentará en un 2.40 unidades.