Open isouch opened 1 month ago
Hi!
you can obtain this equations and the coefficients in the same way that you would get them for a regular bn in bnlearn. If we have this code for example:
library("dbnR")
library("data.table")
dt <- dbnR::motor
dt_train <- dt[1:2800]
dt_test <- dt[2801:3000]
size <- 2
net <- dbnR::learn_dbn_struc(dt_train, size, method = "dmmhc")
f_dt_train <- dbnR::fold_dt(dt_train, size)
f_dt_test <- dbnR::fold_dt(dt_test, size)
fit <- dbnR::fit_dbn_params(net, f_dt_train)
Then you can get the coefficients of any node with the fit
obtained from fit_dbn_params()
:
Afterwards, any coefficient can be accessed with something like fit$ambient_t_0$coefficients
, given that this fit is an instance of the class 'dbn.fit', which inherits from the original 'bn.fit' class in bnlearn.
If, on the other hand, you want to modify these coefficients, then the sintax gets trickier:
tmp <- list("coef" = fit$ambient_t_0$coefficients, "sd" = fit$ambient_t_0$sd)
tmp$coef[2] <- -2e-4
fit$ambient_t_0 <- tmp
The code above changes the original value for the second coefficient of ambient_t_0 to -2e-4. This list sintax is a little bit weird, but if one tries to directly modify the values inside coef, then bnlearn will throw an exception and it will not allow such changes.
Best regards
Hello,
I would like to check how could I get the regression equations between each node and their parents separately to later perform a meta-regression study, if possible. I already have the DBN structure. Is there any way to get them using the dbnR parameter learning step using mle-g?
Thank you in advance.
Best regards, Irene