Skip to content
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

missing = "pairwise" does not take effect #14

Open
psychelzh opened this issue Apr 14, 2024 · 2 comments
Open

missing = "pairwise" does not take effect #14

psychelzh opened this issue Apr 14, 2024 · 2 comments

Comments

@psychelzh
Copy link

For example,

dat <- matrix(rnorm(1000), ncol = 10)
dat[sample(length(dat), 100)] <- NA
x <- kfa::kfa(dat, missing = "pairwise")
#> Power analysis indicates the sample size is too small for k-fold cross validation.
#>     Adjust assumptions or manually create a single holdout sample.
#> [1] "Using 19 cores for parallelization."
#> [1] "Finished EFAs. Starting CFAs"
lavaan::lavInspect(x$cfas[[1]][[1]], "options")$missing
#> [1] "listwise"

Created on 2024-04-14 with reprex v2.1.0

@psychelzh psychelzh changed the title Set missing = "pairwise" does not take effect missing = "pairwise" does not take effect Apr 14, 2024
@psychelzh
Copy link
Author

psychelzh commented Apr 14, 2024

Based on these lines:

kfa/R/k_cfa.R

Lines 16 to 21 in a91d785

sampstats <- sample_stats(data = data,
variables = variables,
ordered = ordered,
estimator = estimator,
missing = missing,
...)

and these lines:

kfa/R/k_cfa.R

Lines 31 to 41 in a91d785

fit <- lavaan::cfa(model = syntax[[c]],
sample.cov = sampstats$cov,
sample.nobs = sampstats$nobs,
sample.th = sampstats$th,
# sample.mean = sampstats$mean,
meanstructure = FALSE,
WLS.V = sampstats$wls.v,
NACOV = sampstats$nacov,
estimator = estimator,
missing = missing,
parameterization = "delta")

I understand it now. pairwise is used in sample_stats(), from which the statistics are calculated. And these statistics are then fed to cfa() and that, probably, lavaan will ignore the missing parameter then. Correct me in case I am wrong.

@knickodem
Copy link
Owner

You are correct. Nonetheless, I am going to keep this open as a reminder to add documentation and testing regarding this point.

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

No branches or pull requests

2 participants