generateNormalPriorData: Prior data generation

View source: R/priorKnowledge.R

generateNormalPriorDataR Documentation

Prior data generation

Description

Generate a prior dataset taking in to account the relationships between the varibles in a given network.

Usage

generateNormalPriorData(graph, data, size, means, deviations = NULL)

Arguments

graph

A network of the class "bn", "graphNEL" or "network".

data

An object of class "data.frame" containing the continuous variables in the dataset.

size

A positive integer indicating the number of records to generate for each variable in the dataset.

means

A "numeric" vector with the average of the variables whose prior information is available. The names in the vector must be the same as the names of the variables in the data.frame.

deviations

A "numeric" vector with the standard deviations of the variables whose prior information is available. The names of the vector must be the same as the names of the variables in the data.frame. If not specified, the standard deviation of each variable is computed from 'data'.

Value

A normal prior data set of class "data.frame".

See Also

rnormMultiv

Examples


## Data
data(ecoli)
data <- ecoli[,-c(1,9)] ## remove sequece.name and class
X <- TrainingandTestData(data, percentage_test = 0.95)
Xtraining <- X$Training
Xtest <- X$Test

## DAG
dag <- LearningHC(data)
plot(dag)

## Means and desviations
colnames(data)

m <- sapply(data, function(x){ifelse(is.numeric(x), mean(x),NA)})
d <- sapply(data, function(x){ifelse(is.numeric(x), sd(x),NA)})


## Prior Dataset
n <- 5600
priorData <- generateNormalPriorData(dag, data = Xtraining, size = n, means = m)
summary(priorData)
ncol(priorData)
nrow(priorData)
class(priorData)


MoTBFs documentation built on April 18, 2022, 5:06 p.m.