donaldRwilliams / BGGM

Bayesian Gaussian Graphical Models
https://donaldrwilliams.github.io/BGGM/
GNU General Public License v2.0
54 stars 14 forks source link

Estimate and explore won't run data frames #75

Open matticervin opened 3 years ago

matticervin commented 3 years ago

I recently got a new computer and installed the most recent versions of R (& R Studio) and BGGM. Now earlier scripts where I use BGGM won't runt.

For example, this code:

fit <- BGGM::explore(df2, type = "mixed", prior_sd = 0.25, iter = 5000, progress = TRUE, impute = TRUE, seed = 1)

Gives this error message:

BGGM: Posterior Sampling Error in BGGM::explore(df2, type = "mixed", prior_sd = 0.25, iter = 5000, : Not a matrix.

I tried to do this:

fit <- BGGM::explore(as.matrix(df2), type = "mixed", prior_sd = 0.25, iter = 5000, progress = TRUE, impute = TRUE, seed = 1)

Which gives this error code:

BGGM: Posterior Sampling Error in BGGM::explore(as.matrix(df2), type = "mixed", prior_sd = 0.25, : Not compatible with requested type: [type=character; target=double].

donaldRwilliams commented 3 years ago

hey. I am not sure what the issue could be as it runs for me.

library(BGGM)

y = BGGM::ptsd

fit = explore(Y = as.matrix(y), type = "mixed")

perhaprs your data are characters which would not work

matticervin commented 3 years ago

Thanks! I troubleshooted my way forward to find that the issue was that a binary variable (1/0) was coded as a factor. When I indicate that the variable is numeric, the estimate/explore functions run. They also run if I keep it the variable as a factor but change the 0-1 coding to a 1-2 coding. I will examine the different approaches affect the estimates.