buildFactorTab: Builds probability tables from Scored Bayes net output.

View source: R/Tables.R

buildFactorTabR Documentation

Builds probability tables from Scored Bayes net output.

Description

Looks for margin statistics in scored Bayes net output, and puts them into tables with rows representing variables and columns representing variable states.

The marginTab function does this for a single individual. The buildMarginTab uses the grand mean across all individuals and the buildFactorTab breaks down groups according to a factor variable. The function build2FactorTab builds a three-way table.

Usage

buildFactorTab(data, fact, stateNames, skillName, reverse = TRUE,
               stem="P", sep=".")
build2FactorTab(data, fact1, fact2, stateNames, skillName,
                reverse = TRUE, stem="P",sep=".")
buildMarginTab(data, stateNames, skillNames, reverse = TRUE,
               stem="P",sep=".")
marginTab(datarow, stateNames, skillNames, reverse = TRUE,
          stem="P",sep=".")

Arguments

data

A data sets of StatShop statistics for many individuals.

datarow

One row of such a data set.

fact

A factor variable according to which to split the data. Length should be the same as the length of data.

fact1

A factor variable according to which to split the data.

fact2

A factor variable according to which to split the data.

stateNames

Names of the variable states.

skillName, skillNames

Name(s) of the proficiency variable(s) to be used.

reverse

Reverse the order of the states for display (i.e., convert from StatShop order of highest first to more natural order of lowest first.

stem

A character string giving a prefix used to indicate variable names.

sep

A character string giving a separator used to separate prefix from variable names.

Details

This looks for columns marked “<stem><sep><skillName>” in the data frame, and builds them into a matrix. It is assumed that all variables have the same number of states and that they are in the same order, and the order is the same as given in stateNames.

The functions buildFactorTab and build2FactorTab really expect their skillNames argument to be a single variable name. However, they should work with multiple variables if suitable values are chosen for the state names.

Value

For marginTab a matrix with columns corresponding to skillNames and rows corresponding to stateNames giving the probabilities for a single individual.

For buildMarginTab a matrix with columns corresponding to skillNames and rows corresponding to stateNames giving the average probabilities for the entire data set.

For buildFactorTab a matrix with columns corresponding to the unique values of fact and rows corresponding to stateNames entries give the average probabilities across the groups.

For build2FactorTab a 3 dimensional array with the first dimension corresponding to the unique values of fact1, the second dimension corresponding to the unique values of fact2 and the last dimension corresponding to stateNames entries give the average probabilities across the groups.

Author(s)

Russell Almond

See Also

stackedBars,compareBars

Examples


data(ACED)

marginTab(ACED.scores[1,], c("H","M","L"), ACED.skillNames$short, reverse = TRUE,
          stem="P",sep=".")

buildMarginTab(ACED.scores, c("H","M","L"), ACED.skillNames$short[1:4],
               reverse = TRUE,
               stem="P",sep=".")

buildFactorTab(ACED.scores, ACED.scores$Cond_code, c("H","M","L"), "sgp",
               reverse = TRUE,
               stem="P", sep=".")

build2FactorTab(ACED.scores, ACED.scores$Sequencing, ACED.scores$Feedback,
                c("H","M","L"), "sgp",
                reverse = TRUE, stem="P",sep=".")



ralmond/CPTtools documentation built on Dec. 27, 2024, 7:15 a.m.