View source: R/hyperDirichlet.R
rescaleTable | R Documentation |
Takes a table representing a conditional probability distribution or a
set of hyper-Dirichlet parameters and rescales the numeric part of the
table. The function rescaleTable()
scales the table by
scaleFactor
, the function normalizeTable()
scales the
function by the sum of the rows, making the result a conditional
probability table.
rescaleTable(table, scaleFactor)
normalizeTable(table)
table |
A data frame describing a conditional probability table. Assumes that the conditions are expressed as factor variables, and all numeric columns represent states of the child variable. |
scaleFactor |
A scalar or vector of length equal to the number of
rows of |
For rescaleTable()
, every numeric column of table
is
multiplied by scaleFactor
. This can be used to create a set of
hyper-Dirichlet parameters by multiplying a conditional probability
table by the effective sample size.
For normalizeTable()
, the scaleFactor
is set to be
1/rowSums(table)
(excluding the factor variables) so that the
resulting table is a proper conditional probability table.
A data frame of the same shape as table
with the numeric
entries suitably scaled.
The function scaleTable
does a similar rescaling, only
it works with a separate ‘Sum’ and ‘Scale’ columns in
the table.
Russell Almond
getTableStates
, scaleTable
#conditional table
X2.ptf <- data.frame(Theta=c("Expert","Novice"),
correct=c(4,2),
incorrect=c(2,4))
X2.t99 <- rescaleTable(X2.ptf,99/6) #Reweight to effective samples size of 99
X2.t31 <- rescaleTable(X2.ptf,c(3,1)) #Weight expert prior 3 times more than
#novice prior.
X2.dtf <- normalizeTable(X2.ptf)
#Unconditional table
Theta.ptf <- data.frame(Expert=3,Novice=3)
Theta.t100 <- rescaleTable(Theta.ptf,100/6) #Reweight to effective
#sample size of 100
Theta.dtf <- normalizeTable(Theta.ptf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.