Learn R Programming

gRain (version 1.4.5)

grain_predict: Make predictions from Bayesian network

Description

Makes predictions (either as the most likely state or as the conditional distributions) of variables conditional on finding (evidence) on other variables in an independence network.

Usage

# S3 method for grain
predict(
  object,
  response,
  predictors = setdiff(names(newdata), response),
  newdata,
  type = "class",
  ...
)

Value

A list with components

pred

A list with the predictions

pFinding

A vector with the probability of the finding (evidence) on which the prediction is based

Arguments

object

A grain object

response

A vector of response variables to make predictions on

predictors

A vector of predictor variables to make predictions from. Defaults to all variables that are note responses.

newdata

A data frame

type

If "class", the most probable class is returned; if "distribution" the conditional distribution is returned.

...

Not used

Author

Søren Højsgaard, sorenh@math.aau.dk

References

Søren Højsgaard (2012). Graphical Independence Networks with the gRain Package for R. Journal of Statistical Software, 46(10), 1-26. https://www.jstatsoft.org/v46/i10/.

See Also

grain

Examples

Run this code
example("example_chest_cpt")
data(chestSim500)

chest.bn <- grain(compileCPT(chest_cpt))
nd <- chestSim500[1:4]

predict(chest.bn, response="bronc", newdata=nd)
predict(chest.bn, response="bronc", newdata=nd, type="distribution")

Run the code above in your browser using DataLab