How to do it...

We will work with the same network used for the previous exercise, and we will plot the network using the bnviewer package:

  1. We formulate the same model as before, with the same code:
library("bnviewer")library("bnlearn")data = read.csv("https://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.data")colnames(data) = c("sex","length","diameter","height","whole_weight", "shucked_weight",  "viscera_weight", "shell_weight","rings") data$rings = log(data$rings) dag = model2network("[sex][length|sex][diameter|sex][height|sex] [whole_weight|length:diameter:height][shucked_weight|length:diameter:height] [viscera_weight|length:diameter:height][shell_weight|length:diameter:height] [rings|whole_weight:shucked_weight:viscera_weight:shell_weight]") ...

Get R Statistics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.