data_prob2: data_prob2

View source: R/data_prob2.R

data_prob2R Documentation

data_prob2

Description

Generates a nrowxncol matrix with probabilities/frequencies. If data is given it will be normalized such that sum(data[is.finite(data)])==1. If no rownames or colnames are given then event names from LETTERS are used. The returned matrix will have the following attributes:

  • marginals a list of the row anc column marginal distributions,

  • byrow a matrix with conditional probabilities by row,

  • bycol a matrix with conditional probabilities by column,

  • expected a matrix with the expected probabilities under independence, and

  • prob a vector of all probabilities computed (except the expected ones).

Usage

data_prob2(
  data = NULL,
  nrow = 2,
  ncol = 2,
  colnames = NULL,
  rownames = NULL,
  ...
)

Arguments

data

an optional data vector. Non-atomic classed R objects are coerced by as.vector and all attributes discarded.

nrow

numeric: desired number of rows (default: 2)

ncol

numeric: desired number of columns (default: 2)

colnames

character: names of column events

rownames

character: names of row events

...

further parameters given to ddiscrete()

Value

a matrix and some attributes

Examples

x <- data_prob2()
str(x)
data_prob2(colnames="E")
data_prob2(nrow=3)

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.