Open QMmmmLiu opened 3 years ago
Hi. Can you share the data with me so that I can take a look at what might be causing the error ?
drwwilliams@ucdavis.edu
I think I found the issue. Try the following
Y <- sapply(netdat, as.numeric)
fit <- estimate(Y, type = "mixed",
impute = TRUE,
iter = 1000)
which imputes the data while fitting. For some reason, this works but removing the NAs produces the error you noted above.
Also, for type = ordinal
, all variables must have the same number of categories. I will note this in the documentation.
Thanks for working on this. I applied the code but received this error:
BGGM: Posterior Sampling
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
error: wishrnd(): given matrix is not symmetric positive definite
**************************************************|
Error in estimate(Y, type = "mixed", impute = TRUE, iter = 1000) :
wishrnd(): given matrix is not symmetric positive definite
In addition: Warning message:
In estimate(Y, type = "mixed", impute = TRUE, iter = 1000) :
imputation during model fitting is
currently only implemented for 'continuous' data.
Try installing the developmental version
if (!requireNamespace("remotes")) {
install.packages("remotes")
}
remotes::install_github("donaldRwilliams/BGGM")
It works! Thanks. A few additional questions regarding mixed-type:
Thanks again.
Follow-up question: it seems that the same issue persist for the zero_order_cors()
function when type is specified as mixed.
Thanks for bringing that to my attention. If you want to get the correlations, you can fit the model as above, and then use pcor_2_cor()
which just converts the partials to zero order correlations. So if the above works, then that will work as well.
Hello Donald,
I am using your package to estimate networks in the Bayesian approach for ordinal variables. I would like to have a related question. As you mentioned above, the algorithm works only when the ordinal variables have the same list of categories. I see this when I make the first run.
> exam2 = data.frame(hungry=kossa$phy_hungry, tired=kossa$phy_tired)
> apply(exam2, 2, table)
$hungry
1 2 3 4
984 307 166 14
$tired
1 2 3 4 5
422 682 307 57 3
> estimate(exam2, type = "ordinal")
BGGM: Posterior Sampling
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Error: min(): object has no elements
In addition: Warning message:
In estimate(exam2, type = "ordinal") : imputation during model fitting is
currently only implemented for 'continuous'
and 'mixed' data.
I then change variable tired by collapsing levels 4 and 5, then the algorithm works
> exam3 = exam2
> for (i in 1 : dim(exam2)[1]){
+ if (!is.na(exam2$tired[i]) & exam2$tired[i] == 5){
+ exam3$tired[i]=4
+ }
+ }
> apply(exam3, 2, table)
hungry tired
1 984 422
2 307 682
3 166 307
4 14 60
> estimate(exam3, type = "ordinal")
BGGM: Posterior Sampling
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
BGGM: Finished
BGGM: Bayesian Gaussian Graphical Models
---
Type: ordinal
Analytic: FALSE
Formula: ~ 1
Posterior Samples: 5000
Observations (n):
Nodes (p): 2
Relations: 1
---
Call:
estimate(Y = exam3, type = "ordinal")
---
Date: Wed Jul 12 11:52:56 2023
Warning message:
In estimate(exam3, type = "ordinal") : imputation during model fitting is
currently only implemented for 'continuous'
and 'mixed' data.
May I please have two questions?
if (!requireNamespace("remotes")) {
install.packages("remotes")
}
remotes::install_github("donaldRwilliams/BGGM")
Thank you so much! Kr, Trung Dung.
Hi Donald,
Thanks for the awesome package. I am trying to run estimate with 15 variables, first six variables are ordinal variables on a 5-point Likert Scale (from 1 to 5) and the latter 9 variables are on a 4-point Likert scale (from 1 to 4).
15 variables are stored in the matrix
netdat
bnet=estimate(netdat,type="mixed")
returns the errorbnet=estimate(netdat,type="ordinal")
returns the errorbnet=explore(netdat2,type="ordinal")
returns the errorestimate()
with Ordinal/Mixed with just the 5-point Likert scale variables or just the 4-point Likert scale variables could run without errors.explore()
withtype="mixed"
could run without errors.Any help would be appreciated to run
estimate()
with all variables in eithermixed
orordinal
type. Thanks!