OffsetGadget: Shiny gadget for editinging (offset) conjuctive and...

View source: R/shinyNode.R

OffsetGadgetR Documentation

Shiny gadget for editinging (offset) conjuctive and disjunctive pnodes

Description

These functions open a shiny application (in a browser window or other location) for editing a Pnode object. To reduce the complexity, the display assumes that PnodeLink(pnode) is partialCredit or gradedResponse, and that PnodeLink(pnode) is Compensatory (Conjunctive or Disjunctive are also possibilities, but usually, the OffsetGadget is a better parameterization for these rules).

Usage

MakeOffsetGadget(pnode, color = "plum")
OffsetGadget(pnode, color="plum",viewer=shiny::paneViewer())

Arguments

pnode

A Pnode object to be modified.

color

A base color to use for barcharts (see barchart.CPF). Execute colors() for a list of choices.

viewer

This is passed to the viewer argument of shiny::runGadget.

Details

The CompensatoryGadget assumes that:

  • The link function is partialCredit

  • There is a single rule for all states, and PnodeQ(pnode)=TRUE.

  • One of the multiple-b rules: OffsetConjunctive or OffsetDisjunctive is used, so that there is one beta for each parent.

  • There is either a single alpha, or one alpha for each state except the last, which is a reference state.

This is the recommended way to model conjuctive and disjunctive models (using a separate difficulty/demand for each parent).

Value

The function MakeOffsetGadget returns a list of two functions, ui and server. These are meant to be passed to shiny::runApp to generate the actual app.

The function OffsetGadget will return the pnode object or throw a ‘Cancel-Error’.

Author(s)

Russell Almond

References

Almond, R. G. (2015) An IRT-based Parameterization for Conditional Probability Tables. Paper presented at the 2015 Bayesian Application Workshop at the Uncertainty in Artificial Intelligence Conference.

See Also

Pnode, calcDPCFrame, barchart.CPF

CompensatoryGadget, RegressionGadget, DPCGadget

Examples

## Not run: 
library(PNetica) ## Requires implementation
sess <- NeticaSession()
startSession(sess)

tNet <- CreateNetwork("TestNet",sess)

theta1 <- NewDiscreteNode(tNet,"theta1",
                         c("VH","High","Mid","Low","VL"))
PnodeStateValues(theta1) <- effectiveThetas(PnodeNumStates(theta1))
PnodeProbs(theta1) <- rep(1/PnodeNumStates(theta1),PnodeNumStates(theta1))
theta2 <- NewDiscreteNode(tNet,"theta2",
                         c("VH","High","Mid","Low","VL"))
PnodeStateValues(theta2) <- effectiveThetas(PnodeNumStates(theta2))
PnodeProbs(theta2) <- rep(1/PnodeNumStates(theta1),PnodeNumStates(theta2))

## CompensatoryGadget

partial3 <- NewDiscreteNode(tNet,"partial3",
                            c("FullCredit","PartialCredit","NoCredit"))
PnodeParents(partial3) <- list(theta1,theta2)

## Usual way to set rules is in constructor
partial3 <- Pnode(partial3,rules="OffsetConjuctive", link="partialCredit")
PnodeLnAlphas(partial3) <- 0
PnodeQ(partial3) <- TRUE
PnodeBetas(partial3) <- c(0,1)
BuildTable(partial3)
PnodePriorWeight(partial3) <- 10
BuildTable(partial3)

partial3 <- OffsetGadget(partial3)

## This expression can be used inside an Rmarkdown document
gadget <- MakeOffsetGadget(partial3)
shinyApp(gadget$ui,gadget$server,options(height=2000))

DeleteNetwork(tNet)
stopSession(sess)

## End(Not run)


ralmond/Peanut documentation built on Sept. 19, 2023, 8:27 a.m.