Learn R Programming

gRapHD (version 0.2.5)

stepb: Stepwise backward selection

Description

A function to perform stepwise backward selection to minimize AIC or BIC.

Usage

stepb(G, dataset, fixed.edges = NULL, stat = "BIC")

Arguments

G

A gRapHD object, the initial model.

dataset

A dataframe, whose variables correspond to the nodes of G.

fixed.edges

A boolean vector of length nrow(G@edges). Edges that are TRUE are not removed from the model.

stat

The measure to be minimized, either "BIC" (default) or "AIC".

Value

A gRapHD object.

Details

Performs backward stepwise selection. The initial model must be decomposable. Only edges preserving decomposability are eligible for removal. At each step, the edge resulting in the greatest reduction in BIC (or AIC) is removed. A pure graphical model (i.e. either discrete or continuous) is decomposable iff its graph is triangulated. A mixed graphical models (i.e., with both discrete and continuous variables) is decomposable iff its graph is triangulated and contains no forbidden paths.

Examples

Run this code
# NOT RUN {
data(attitude)
am <- NULL
for (i in 1:6) for (j in (i+1):7) am <- rbind(am, c(i,j))
satG <- new("gRapHD", edges=am, p=7, homog=TRUE, numCat=rep(0,7), vertNames=names(attitude))
G <- stepb(satG, attitude)
# }

Run the code above in your browser using DataLab