Learn R Programming

catnet (version 1.08.2)

cnSetProb-method: Set Probability from Data

Description

The function sets the probability structure of a network from data according to the Maximum Likelihood criterion.

Usage

cnSetProb(object, data)

Arguments

object
a catNetwork
data
a data matrix or data.frame

Value

  • The updated object

Details

The data can be a matrix of indices with rows representing the network nodes, or a data.frame in the alternative, node-column format. The indices range from 1 to the number of categories of the corresponding node. The function changes the probability slot of the object and returns an updated catNetwork. It is a procedure of fitting a network to data by keeping the graph structure unchanged.

Examples

Run this code
library(catnet)
  cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=3)
  psamples <- matrix(as.integer(1+rbinom(10*100, 2, 0.4)), nrow=10)
  rownames(psamples) <- cnet@nodes
  newcnet <- cnSetProb(object=cnet, data=psamples)

Run the code above in your browser using DataLab