Skip to content

Conversation

@mattansb
Copy link
Contributor

Following #119 - this provides two solutions to missing values:

  1. Mean impute them (default)
  2. Allow users to pass the data= argument
library(semTools)
library(emmeans)


data("mtcars")
raw_mtcars <- mtcars
mtcars$hp[1] <- NA
model <- " mpg ~ hp + drat + hp:drat "
fit <- sem(model, mtcars, missing = "fiml.x")




ref_grid(fit, lavaan.DV = "mpg")
#> Warning: 'data' contains missing value. Mean-imputing them.
#> 'emmGrid' object with variables:
#>     hp = 147.87
#>     drat = 3.5966


ref_grid(fit, lavaan.DV = "mpg",
         data = raw_mtcars)
#> 'emmGrid' object with variables:
#>     hp = 146.69
#>     drat = 3.5966

emtrends(fit, ~ drat, var = "hp", lavaan.DV = "mpg",
         data = raw_mtcars)
#>  drat hp.trend      SE  df asymp.LCL asymp.UCL
#>   3.6  -0.0506 0.00899 Inf   -0.0682    -0.033
#> 
#> Confidence level used: 0.95

Created on 2025-02-10 with reprex v2.1.1

@TDJorgensen TDJorgensen merged commit d06ced2 into simsem:master Feb 11, 2025
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants