-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix missing data issue #119
base: master
Are you sure you want to change the base?
Conversation
Hi @rvlenth, For However, for Thanks! # remotes::install_github("mattansb/semTools") # install this PR
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")
(rg <- ref_grid(fit,
lavaan.DV = "mpg",
data = raw_mtcars))
#> 'emmGrid' object with variables:
#> hp = 146.69
#> drat = 3.5966
rg@linfct
#> (Intercept) hp drat hp:drat
#> 1 1 146.6875 3.596563 527.5708
(emM <- emmeans(fit, ~ drat, var = "hp",
lavaan.DV = "mpg",
data = raw_mtcars))
#> drat emmean SE df asymp.LCL asymp.UCL
#> 3.6 20 0.614 Inf 18.8 21.2
#>
#> Confidence level used: 0.95
emM@linfct
#> (Intercept) hp drat hp:drat
#> [1,] 1 146.6875 3.596563 527.5708
(emT <- emtrends(fit, ~ drat, var = "hp",
lavaan.DV = "mpg",
data = raw_mtcars))
#> drat hp.trend SE df asymp.LCL asymp.UCL
#> 3.6 nonEst NA NA NA NA
#>
#> Confidence level used: 0.95
emT@linfct
#> (Intercept) hp drat hp:drat
#> [1,] 0 NA 0 NA |
I'm not at all sure that it isn't intentional. The first call to |
I think it is right the way it is. The setup for the first call to
So if The second call to
where So actually I'm confused by your statement that data is passed the first time and not the second, because what we actually have is data being explicitly passed the second time, and only implicitly passed the first time. |
OK, my bad! It turns out that if |
Hey, this almost fixes the issue. (emT <- emtrends(fit, ~ drat, var = "hp",
lavaan.DV = "mpg",
data = raw_mtcars))
#> Error in lav_data_full(data = data, group = group, cluster = cluster, :
#> lavaan ERROR: some (observed) variables specified in the model are not found in the dataset: mpg This is because the Can we not simply pass the original |
You can use the |
By the way, in your |
Any update on this issue? Has this been added to simsem? |
@patc3 No additional updates from me (emmeans) since my last comment. My repairs to |
Sorry @patc3 - I haven't found the time to get back to this just yet. |
This is a WIP