Learn R Programming

exams.forge (version 1.0.10)

data_prob2: Probability/Frequency Matrix Generation

Description

Generates a nrow × ncol 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 and 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

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

Usage

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

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

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

Value

A matrix and some attributes.

Arguments

data

an optional data vector. Non-atomic classed R objects are coerced by as.vector and all attributes are 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()

Examples

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

Run the code above in your browser using DataLab