Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/make_gRain_CPT.R
Take the required arguments for make_CPT
, compute the nodes states probabilities and format them as ready to use inputs for cptable
.
1 2 3 4 5 6 7 8 9 10 11 |
parent_effects |
list of vectors describing the effects of all parent node states on the value of the child variable. For example, if parent 1 has four states, the respective vector might look like this: c(3,1,0,0). This would imply that the first state of the parent is strongly associated with high values for the child, the second less strongly, and the 3rd and 4th value are associated with equally low values. |
parent_weights |
weight factors for the parent nodes |
b |
parameter for the strength of the parent's influence on the child node. A value of 1 causes no response; 3 is quite strong. |
child_prior |
prior distribution for the states of the child node. |
ranking_child |
vector of length length(child_prior) containing rankings for the child node states on a -1..1 scale. If this is null, evenly spaced rankings on this -1..1 scale are assigned automatically. |
child_states |
optional vector specifying the names of the child states. |
parent_names |
optional vector specifying parent node names. |
parent_states |
list of the same structure as parent_effects containing names for all states of all parents. |
option |
character string. CPT formatting option; either 'grain' or 'bnlearn' (NOT currently implemented). |
make_CPT
does not seems to work well with simple case (i.e. single parent - single child relationship) which case does not worth it!
A matrix containing the Conditional probabilities.
Issoufou Liman
Sjoekvist S & Hansson F, 2013. Modelling expert judgement into a Bayesian Belief Network - a method for consistent and robust determination of conditional probability tables. Master's thesis, Faculty of Engineering, Lund University; http://lup.lub.lu.se/luur/download?func=downloadFile&recordOId=3866733&fileOId=3866740
Eike Luedeling and Lutz Goehring (2018). decisionSupport: Quantitative Support of Decision Making under Uncertainty. R package version 1.103.8. https://CRAN.R-project.org/package=decisionSupport
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | library (gRain)
## Simple nodes specification using gRain package.
Soil_type <- cptable (~Soil_type, values = c(0.05, 0.55, 0.4),
levels = c('Sandy', 'Loamy', 'Clayey'))
Manure_application <- cptable(~Manure_application, values = c(0.3, 0.7),
levels = c('FALSE', 'TRUE'))
## Complex nodes specification.
Soil_water_holding_capacity_tmp <- make_gRain_CPT(
parent_effects = list(c(0, 2.5, 3), c(0, 2)),
parent_weights = c(2,1),
b = 3,
child_prior = c(0.2,0.5,0.3),
child_states = c('Low', 'Medium', 'High'),
parent_states = list(c('Sandy', 'Loamy', 'Clayey'), c('FALSE', 'TRUE'))
)
Soil_water_holding_capacity_values <- Soil_water_holding_capacity_tmp$values
Soil_water_holding_capacity_levels <- Soil_water_holding_capacity_tmp$levels
Soil_water_holding_capacity <- cptable (
~Soil_water_holding_capacity|Soil_type:Manure_application,
values = Soil_water_holding_capacity_values,
levels = Soil_water_holding_capacity_levels)
## Compile conditional probability tables
network <- compileCPT(list(Soil_type, Manure_application, Soil_water_holding_capacity))
## Graphical Independence Network ####
network <- grain(network)
network
plot (network)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.