0% found this document useful (0 votes)
2 views1 page

Bayesian Network Example in R

This document demonstrates an example of using the bnlearn package in R to build a Bayesian network model. It generates random normal data across 4 variables (Height, BMI, SBP, FBS) for 1000 observations. It then transforms the data and builds a Bayesian network model (res.Data2) from it, showing the network structure. It also sets and examines the strength of the arc between the FBS and BMI nodes in the modeled network.

Uploaded by

lincolour
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Bayesian Network Example in R

This document demonstrates an example of using the bnlearn package in R to build a Bayesian network model. It generates random normal data across 4 variables (Height, BMI, SBP, FBS) for 1000 observations. It then transforms the data and builds a Bayesian network model (res.Data2) from it, showing the network structure. It also sets and examines the strength of the arc between the FBS and BMI nodes in the modeled network.

Uploaded by

lincolour
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

An example of bnlearn

library(bnlearn) norm <- rnorm(4000) Data <- matrix(norm, nrow=1000, ncol=4, byrow=T) colnames(Data) <- c("Height", "BMI", "SBP", "FBS") Data <- [Link](Data) Data2 <- Data Data2$Height <- 170 + Data$Height*10 Data2$SBP <- 120 + Data$SBP*10 Data2$BMI <- 22 + Data$Height*2 + Data$BMI*2 + Data$SBP*2 Data2$FBS <- 90 + (Data2$BMI-22)*5 + Data$FBS*10 Data2 <- [Link](Data2) res.Data2 = gs(Data2) plot(res.Data2) res.arc2 <- [Link](res.Data2, "FBS","BMI") [Link](res.arc2, Data2)

You might also like