Learn R Programming

catnet (version 1.00.0)

cnSamplesPert-method: Perturbed Samples from Network

Description

Generates perturbed samples from of a catNetwork object.

Usage

cnSamplesPert(object, perturbations, numsamples=1, output="frame")

Arguments

object
a catNetwork
perturbations
a matrix
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

A perturbed sample is a sample having nodes with predefined, thus not random, values. Non-perturbed nodes, the nodes which values have to be set, are designated with zeros in the perturbation matrix and their values are generated conditional on the values of their parents. The non-zero values in the perturbation matrix remain the same in the sample matrix but the zero ones are filled according to the probability law of the network. As in cnSamples function, the result can be in matrix or data frame format, depending on the output parameter.

See Also

cnSamples

Examples

Run this code
cnet <- cnRandomCatnet(numnodes=10, maxParents=3, numCategories=3)
  nsamples <- 20
  perturbations <- matrix(rbinom(10*nsamples, 2, 0.4), nrow=10)
  ## generate a perturbed sample of size 100 from cnet
  psamples <- cnSamplesPert(object=cnet, perturbations, numsamples=nsamples)

Run the code above in your browser using DataLab