如何检索简单 lavaan 模型整体显着性的 p 值?
与使用 lm() 完成的标准线性回归中 F 统计量的 p 值类似。
model <- sem('criterion ~ predictor1 + predictor2', data = data, missing = "FIML", fixed.x = FALSE, se = "BOOTSTRAP", bootstrap = 5000)
summary(model, standardize = FALSE, ci = TRUE, rsquare = T)
有几个选项您可以尝试!您可以首先将其传递给摘要,而不是摆弄 S4 对象的访问元素。另一种选择是让
purrr::pluck
做肮脏的工作。
library(lavaan)
#> This is lavaan 0.6-17
#> lavaan is FREE software! Please report any bugs.
library(tidyverse)
data(PoliticalDemocracy, package = 'lavaan')
model <- '
# measurement model
ind60 =~ x1 + x2 + x3
dem60 =~ y1 + y2 + y3 + y4
dem65 =~ y5 + y6 + y7 + y8
# regressions
dem60 ~ ind60
dem65 ~ ind60 + dem60
# residual correlations
y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8'
fit = sem(model, data = PoliticalDemocracy, missing = "FIML")
tidyish_way = fit |>
pluck('test', 'standard', 'pvalue')
base_way = summary(fit, standardize = FALSE,
ci = TRUE, rsquare = TRUE)$test$standard$pvalue
print(tidyish_way)
#> [1] 0.3291804
print(base_way)
#> [1] 0.3291804
summary(fit)
#> lavaan 0.6.17 ended normally after 68 iterations
#>
#> Estimator ML
#> Optimization method NLMINB
#> Number of model parameters 31
#>
#> Number of observations 75
#>
#> Model Test User Model:
#>
#> Test statistic 38.125
#> Degrees of freedom 35
#> P-value (Chi-square) 0.329
创建于 2024-05-14,使用 reprex v2.1.0