bn.prep.data: Preprocess data

Description Usage Arguments Value Examples

View source: R/bayesian.R

Description

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.

Usage

1
2
3
4
5
6
7
8
bn.prep.data(
  dag,
  data,
  id = "patient_id",
  time_col = "day",
  factorize = FALSE,
  normalize = FALSE
)

Arguments

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

Value

data frame

Examples

 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)

thogaertner/cinof1 documentation built on Jan. 8, 2022, 10:37 a.m.