\name{parseDist} \alias{parseDist} \alias{xmlDistribution} \title{Translates between distribution object and XML} \usage{ parseDist(xNode) xmlDistribution(dist) } \arguments{ \item{xNode}{\code{XMLNode} corresponding to a \code{} element.} \item{dist}{A \code{distribution} object.} } \description{ The function \code{parseDist} decodes an \code{} element from a StatShop Graphical Model (GM) file and produces a \code{distribution} object. The function \code{xmlDistribution} does the inverse. } \references{ \url{http://research.ets.org/~ralmond/StatShop/dataFormats.html} } \author{Russell Almond} \seealso{ \code{\link[XML]{XMLNode}}, \code{\link{distribution}}, \code{\link{getEMParametersForAMD}},\code{\link{getLMParametersForAMD}} } \examples{ ## Pardon us while we build some distributions. ## Build the Parameter Set ## Need to get names correct for everything to work. pnames <- c("Task Difficulty", "Relative Importance(Reading)", "Level Difficulty Increment(Outcome_R,Good)") pvalue <- c(1,0,0.5) names(pvalue) <- pnames pcov <- matrix(0,nrow=length(pnames),ncol=length(pnames), dimnames=list(pnames,pnames)) diag(pcov) <- c(0.3164,0.0207, 0.01) ps1 <- parameterVector(pvalue,"Outcome_R",pcov) table1 <- matrix(c(0.79894674, 0.06863273, 0.1324205, 0.22270014, 0.09812116, 0.6791787, 0.02023846, 0.01269671, 0.9670648),nrow=3,byrow=3) ## These come from running calcDSTable with the above parameters. colnames(table1) <- c("Good","Okay","Poor") dtable1 <- data.frame(Reading=c("Advanced","Basic","Novice"),table1) ## DiBello--Samejima style dist1 <- distribution(c("Reading"),"Outcome_R", "Compensatory Distribution", table=dtable1, parameterSet = ps1) table2 <- matrix(c(0.7, 0.2, 0.1, 0.3, 0.4, 0.3, 0.1, 0.2, 0.7), nrow=3,byrow=3) ## These come from running calcDSTable with the above parameters. colnames(table2) <- c("Good","Okay","Poor") dtable2 <- data.frame(Reading=c("Advanced","Basic","Novice"),table2) ptable2 <- data.frame(Reading=c("Advanced","Basic","Novice"),table2,Scale=1,Sum=10) ## HyperDirichlet style dist2 <- distribution(c("Reading"),"Outcome_R", "HyperDirichlet Distribution", table=dtable2, parameterTable = ptable2) ## On to the real examples dist1node <- xmlDistribution(dist1) dist1rt <- parseDist(dist1node) dist2node <- xmlDistribution(dist2) dist2rt <- parseDist(dist2node) \dontshow{ ## For some reason identical fails, so need to do this the hardway stopifnot( identical(dist1$cond,dist1rt$cond), identical(dist1$cons,dist1rt$cons), identical(dist1$type,dist1rt$type), identical(dist1$table,dist1rt$table), identical(dist1$parameterSet,dist1rt$parameterSet), identical(dist1$parameterTable,dist1rt$parameterTable), identical(dist2$cond,dist2rt$cond), identical(dist2$cons,dist2rt$cons), identical(dist2$type,dist2rt$type), identical(dist2$table,dist2rt$table), identical(dist2$parameterSet,dist2rt$parameterSet), identical(dist2$parameterTable,dist2rt$parameterTable) ) } } \keyword{interface}