Load preprocessed data and trained model

library(wrmbn)
data("data")
data("preprocessed")
data("trained_models")

Impute missing data

library(wrmbn)
head(data)
continuous_variables <- preprocessed$continuous_variables
discrete_variables <- preprocessed$discrete_variables
desire_layers <- preprocessed$desire_layers
time_column <- "date"
normalize_type <- preprocessed$normalize_tye
normalizers <- preprocessed$normalizers
fitted <- trained_models$hc$fitted

imputed_data <- impute_missing_data(fitted, data, continuous_variables, discrete_variables,
                                time_column, normalize_type, normalizers, debug = FALSE)
head(imputed_data)

Predict data

library(wrmbn)

predictor_data <- data[2019:2020, c("date", "HND", "HCT")]
print(predictor_data)
normalizers <- preprocessed$normalizers
normalize_type <- preprocessed$normalize_tye
fitted <- trained_models$hc$fitted
continuous_variables <- c("HND", "HCT")
discrete_variables <- c()
predicted_nodes <- c("MBT")
number_layers <- 3

predicted_data <- predict_data(fitted, predictor_data, predicted_nodes, number_layers,
            continuous_variables, discrete_variables,
            time_column = "date", "%m/%d/%y", normalizers, normalize_type,
            method = "lw", TRUE)

print(predicted_data)
actual_data <- data[2019:2021, c("date", "HND", "HCT", "MBT")]
print(actual_data)

Estimate probabilities



bayes-modeling/wrmbn documentation built on Dec. 19, 2021, 6:45 a.m.