Open LiuJL1100 opened 1 year ago
I also came across this problem.
My mgm version is "1.2-14", R version is "4.3.2 (2023-10-31)", and RStudio version is "2023.09.1+494"
When I ran example 1 in the mgmsampler() function, I got the same warning message. However, sexamples 2 and 3 (focus on 3-way interaction) are fine. I wonder if there is any problem with 2-way interaction or else.
Hoping for solutions. Thanks.
I went through the code of the function, and I think this problem might occur because the code: f (!(class(interactions[[i]][[row]]) %in% c("array", "matrix")))
in
for (i in 1:n_order) { n_ints <- length(interactions[[i]]) if (n_ints > 0) for (row in 1:n_ints) if (!(class(interactions[[i]][[row]]) %in% c("array", "matrix"))) stop("The parameters of each interaction have to be provided as k-dimensional array.") }
returns more than one logic element (as for example 1, the result is TRUE TRUE
). Therefore, the condition has length > 1
.
To solve this problem, I defined a new function mgm_sampler
on my own, and replaced the original code with
for(i in 1:n_order) { n_ints <- length(interactions[[i]]) if(n_ints > 0) { for(row in 1:n_ints) { if(!inherits(interactions[[i]][[row]], "array") && !inherits(interactions[[i]][[row]], "matrix")) { stop("The parameters of each interaction have to be provided as k-dimensional array.") } } } }
Hope this solution can help. :)
Hello,
I was hoping to use this for some simulations I need to run. I just installed the latest developmental version and it looks like this error is still present (it was still present in the CRAN version as well). I tried the workaround posted by Jiahao-ZHU above but I can't quite get that to work. So I was just wondering whether anyone has found another workaround or whether an update to the developmental version could be made? Many thanks.
I'll try to fix this asap. Meanwhile, an alternative and possibly more convenient way to simulate data with multivariate dependencies between variables with different domains is to simulate from a DAG. This avoids the issues arising from needing a proper joint distribution over all variables (see Appendix F in https://osf.io/preprints/psyarxiv/926pv and the accompanying code in corresponding reproducibility repo).
Great, thanks Jonas, and for the tip and link as well.
Hi Jonas,
I run the exampling code in the documantation of mgmsampler function, but got the warning message:
How to slove this problem?