Description Usage Arguments Value Examples
This function is preprocessing a dataframe to be used for bn.fit. For that, columns were transformed into factors and lags were created if required.
1 2 3 4 5 6 7 8 | bn.prep.data(
dag,
data,
id = "patient_id",
time_col = "day",
factorize = FALSE,
normalize = FALSE
)
|
dag |
result from bn.prep.dag |
data |
R data frame to fit the Bayesian network |
id |
column name of patient identifier (only needed when lag column) |
time_col |
column name of time (integer expected, only needed when lag column) |
factorize |
specify weather all columns should be factors or not |
data frame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # specify column names
id <- "patient_id"
time_col <- "day"
# Load data
load("data/simpatdag.rda")
load("data/simpatdat.rda")
# Dag preprocessing
bn.dag <- bn.prep.dag(simpatdag)
# Data Preprocessing (Factorization)
simpatdat$Uncertain_Low_Back_Pain <- as.factor(simpatdat$Uncertain_Low_Back_Pain)
simpatdat$Activity <- cut(simpatdat$Activity, 3, labels=c("low Activity", "middle Activity", "high Activity"))
bn.data <- bn.prep.data(bn.dag, simpatdat, id, time_col)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.