\name{StatisticToMeta} \alias{StatisticToMeta} \alias{StatisticToMetaMap} \title{Creates a StatisticMeta object from a Statistic object} \description{ This takes a \code{\link{Statistic}} object from an Assessment Model Description and turns it into a \code{\link{StatisticMeta}} object suitable for including in a Pretest Description. } \usage{ StatisticToMeta(stat, vars, codeRule = NULL) StatisticToMetaMap } \arguments{ \item{stat}{An object of type \code{\link{Statistic}}.} \item{vars}{A list of \code{\link{varDescription}} objects. The names of the elements should correspond to the variable names.} \item{codeRule}{A coding rule value for passing to \code{\link{integerCodes}}. Should be an integer or \code{NULL}.} } \details{ This creates a new \code{StatisticMeta} object from a \code{Statistic} object. The \code{type} of the result will depend on the value of \code{stat$class} by looking this up in the table defined by \code{StatisticToMetaMap}. The \code{name} of the \code{Statistic} is used as the \code{name} of the \code{StatisticMeta} and the \code{columnID} is generated by substituting \sQuote{.} for \sQuote{(} and removing \sQuote{)} in the \code{name}. For \dQuote{Probability} type statistics, a trailing \sQuote{.} is added to the \code{columnID}. In the case of \dQuote{Probability} statistics, the \code{levels} field is set from the \code{levels} field of the \code{\link{varDescription}} for the \code{reportingVariable}. This is found by looking it up by name in the \code{vars} argument. In the case of \dQuote{Discrete} statistics, the \code{transtlationTable} field is set by applying \code{\link{integerCodes}} to the \code{levels} field of the \code{\link{varDescription}} for the \code{reportingVariable}. This is found by looking it up by name in the \code{vars} argument. The \code{codeRule} argument is used to control how these are coded in the CSV file: a value of \code{NULL} produces string codes and a numeric value produces integer codes. } \value{ An object of type \code{\link{StatisticMeta}} (see Details). } \references{ \url{http://research.ets.org/~ralmond/StatShop/dataFormats.html} } \seealso{ \code{\link{Statistic}}, \code{\link{StatisticMeta}}, \code{\link{varDescription}}, \code{\link{integerCodes}} } \examples{ Skill1 <- varDescription("Skill1","Skill1",role="SM", levels=c("Advanced","Proficient", "Basic", "Below Basic")) Skill2 <- varDescription("Skill2","Skill2",role="SM", levels=c("Proficient", "Not Proficient")) varlist <- list(Skill1=Skill1, Skill2=Skill2) S1.margin <- Statistic(name="margin(Skill1)", class="Bayes Net Margin", reportOnUpdate=TRUE, model="System", reportingVars="Skill1") S2.mean <- Statistic(name="mean(Skill2)", class="Bayes Net Mean", reportOnUpdate=TRUE, model="System", reportingVars="Skill2") S2.mode <- Statistic(name="mode(Skill2)", class="Bayes Net Mode", reportOnUpdate=TRUE, model="System", reportingVars="Skill2") S1.margin.meta <- StatisticToMeta(S1.margin, varlist) S2.mean.meta <- StatisticToMeta(S2.mean, varlist) S2.mode.meta <- StatisticToMeta(S2.mode, varlist, 1) ## Integer coding \dontshow{ stopifnot( S1.margin.meta$type == "Probability", S2.mean.meta$type == "Real", S2.mode.meta$type == "Discrete", S1.margin.meta$name == S1.margin$name, S2.mean.meta$name == S2.mean$name, S2.mode.meta$name == S2.mode$name, all.equal(S1.margin.meta$levels,Skill1$levels), all.equal(S2.mode.meta$translationTable, c("Proficient"=2,"Not Proficient"=1)) ) } } \keyword{manip}