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

Issues with conditional indirect effects when using a categorical moderator #1

Open
npudles opened this issue Feb 14, 2024 · 1 comment

Comments

@npudles
Copy link

npudles commented Feb 14, 2024

Hi,

I have an issue with the manymome functions cond_indirect_effects() and mod_levels() when using a categorical moderator with two categories.

I get these warning and error messages :

Warning in seq_len(ncol(w_gp)): first element used of 'length.out' argument
Error in seq_len(ncol(w_gp)) : argument must be coercible to non-negative integer

I'm following the steps from Cheung & Cheung (2023) manymome:__ An R package for computing the indirect effects, conditional effects, and conditional indirect effects, standardized or unstandardized, and their bootstrap confidence intervals, in many (though not all) models.

I don't understand what's the issue. Is it a bug or is it an issue with my code/data ?

Mind that I don't have this issue when I'm using a continuous moderator with the same data.

Thanks in advance

library(lavaan)
#> This is lavaan 0.6-17
#> lavaan is FREE software! Please report any bugs.
library(manymome)
##Sample data
df <- data.frame(
     Intense = c(1.20302400035313,0.377413381825115,
                 -1.18646351469919,1.20057716684428,1.20138456799171,
                 -2.7774605624413,-1.94239715523117,0.402302832389528,-0.421912163704315,
                 0.331669138980736),
     CatPers = c("0.792961214431443","0.792961214431443",
                 "-1.25872969475283","-1.25872969475283","-1.25872969475283",
                 "0.792961214431443","0.792961214431443","-1.25872969475283",
                 "0.792961214431443","0.792961214431443"),
         Pos = c(-0.233043705579646,-0.376337459099043,
                 -0.530671521945183,1.34621539413837,-0.957223025488462,
                 0.90322432738519,-0.640637299527499,-0.158533233160109,
                 0.27334450686968,0.0162900160068483),
         Wfc = c(1.00645422416079,0.418767308104094,
                 0.543193979890933,0.150878583032073,0.671868144845523,
                 -0.203760346081739,0.522581840151886,0.123494795372463,0.20299495139938,
                 0.211670048655376)
)

##Dummy variable based on a categorical variable with two categories
corsci <- factor2var(df$CatPers, 
                     x_contrasts = "contr.treatment")
df[, "corsci"] <- corsci

##Interaction term
df$Intense_corsci <- df$Intense*df$corsci

##Structural model
mtest <- "
Pos ~ Intense + Intense_corsci + corsci
Wfc ~ Pos"

test.fit <- sem(mtest, df, std.lv = TRUE, fixed.x = FALSE, missing = "fiml")

##Conditional indirect effect
outest <- cond_indirect_effects(wlevels = "corsci",
                        x = "Intense",
                        y = "Wfc",
                        m = "Pos",
                        fit = test.fit)
#> Warning in seq_len(ncol(w_gp)): seul le premier élément de l'argument
#> 'length.out' est utilisé
#> Error in seq_len(ncol(w_gp)): l'argument doit être convertible automatiquement en un entier non négatif

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

@gaborcsardi
Copy link

Hi, this is a read only mirror of CRAN, please see the package authors in the DESCRIPTION file. Look for Maintainer, BugReports and URL. Thanks!

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