Learn R Programming

catnet (version 1.00.0)

cnSamples-method: Samples from Network

Description

Generates samples from of a catNetwork object.

Usage

cnSamples(object, numsamples = 1, output="frame")

Arguments

object
a catNetwork
numsamples
an integer, the number of samples to be generated
output
a character, the output format. Can be a data.frame or matrix.

Value

  • A matrix or data.frame of node categories

Details

If the output format is "matrix" then the resulting sample matrix is in row-node format - the rows correspond to the object's nodes while the individual samples are represented by columns. If the output format is "frame", which is by default, the result is a data frame with columns representing the nodes and levels the set of categories of the respected nodes.

See Also

cnSamplesPert

Examples

Run this code
cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=3)
  ## generate a sample of size 100 from cnet
  psamples <- cnSamples(object=cnet, numsamples=100, output="frame")

Run the code above in your browser using DataLab