Description Usage Arguments Details Value Note Author(s) See Also Examples
Assign, extract or compute various quantities of interest from an object
of class bn.fit
, bn.fit.dnode
, bn.fit.gnode
or
bn.fit.onode
.
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 28 29 30 31 32 33 34 35 36 37 | ## methods available for "bn.fit"
## S3 method for class 'bn.fit'
fitted(object, ...)
## S3 method for class 'bn.fit'
coef(object, ...)
## S3 method for class 'bn.fit'
residuals(object, ...)
## S3 method for class 'bn.fit'
predict(object, node, data, method = "parents", ..., debug = FALSE)
## S3 method for class 'bn.fit'
logLik(object, data, nodes, by.sample = FALSE, ...)
## S3 method for class 'bn.fit'
AIC(object, data, ..., k = 1)
## S3 method for class 'bn.fit'
BIC(object, data, ...)
## methods available for "bn.fit.dnode"
## S3 method for class 'bn.fit.dnode'
coef(object, ...)
## S3 method for class 'bn.fit.dnode'
predict(object, data, ..., debug = FALSE)
## methods available for "bn.fit.onode"
## S3 method for class 'bn.fit.onode'
coef(object, ...)
## S3 method for class 'bn.fit.onode'
predict(object, data, ..., debug = FALSE)
## methods available for "bn.fit.gnode"
## S3 method for class 'bn.fit.gnode'
fitted(object, ...)
## S3 method for class 'bn.fit.gnode'
coef(object, ...)
## S3 method for class 'bn.fit.gnode'
residuals(object, ...)
## S3 method for class 'bn.fit.gnode'
predict(object, data, ..., debug = FALSE)
|
object |
an object of class |
node |
a character string, the label of a node. |
nodes |
a vector of character strings, the label of a nodes whose loglikelihood components are to be computed. |
data |
a data frame containing the variables in the model. |
method |
a character sting, the method used to estimate predictions. See below. |
... |
additional arguments. See below. |
k |
a numeric value, the penalty per parameter to be used; the
default |
by.sample |
a boolean value. If |
debug |
a boolean value. If |
coef
(and its alias coefficients
) extracts model
coefficients (which are conditional probabilities in discrete
networks and linear regression coefficients in Gaussian networks).
residuals
(and its alias resid
) extracts model
residuals and fitted
(and its alias fitted.values
)
extracts fitted values from fitted Gaussian networks.
If the bn.fit
object does not include the residuals or the
fitted values (for the nodes of interest, in the case of
bn.fit.gnode
objects), both functions return NULL
.
predict
returns the predicted values for node
given the data
specified by data
. Depending on the value of method
, the
predicted values are computed as follows.
parents
: the predicted values are computed by plugging in
the new values for the parents of node
in the local probability
distribution of node
extracted from fitted
.
bayes-lw
: the predicted values are computed by averaging
likelihood weighting simulations performed using all the available
nodes as evidence (obviously, with the exception of the node whose
values we are predicting). The number of random samples which are
averaged for each new observation is controlled by the n
optional argument; the default is 500
. If the variable being
predicted is discrete, the predicted level is that with the highest
conditional probability. If the variable is continuous, the predicted
value is the expected value of the conditional distribution.
Both methods are available for bn.fit
objects; predictions for
bn.fit.dnode
, bn.fit.onode
and bn.fit.gnode
objects
can only be estimated with method = "parents"
. That is the default
method
for bn.fit
objects as well.
predict
returns a numeric vector (for Gaussian networks) or a factor
(for discrete networks).
logLik
returns a numeric vector or a single numeric value, depending
on the value of by.sample
. AIC
and BIC
always return
a single numeric value.
All the other functions return a list with an element for each node in
the network (if object
has class bn.fit
) or a numeric
vector (if object
has class bn.fit.dnode
or bn.fit.gnode
).
Ties in prediction are broken using Bayesian tie breaking, i.e. sampling at random from the tied values. Therefore, setting the random seed is required to get reproducible results.
predict
accepts either a bn
or a bn.fit
object as
its first argument. For the former, the parameters of the network are
fitted on data
, that is, the observations whose class labels the
function is trying to predict.
Marco Scutari
1 2 3 4 5 6 7 8 9 10 11 | data(gaussian.test)
res = hc(gaussian.test)
fitted = bn.fit(res, gaussian.test)
coefficients(fitted)
coefficients(fitted$C)
str(residuals(fitted))
data(learning.test)
res2 = hc(learning.test)
fitted2 = bn.fit(res2, learning.test)
coefficients(fitted2$E)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.