RegressionGadget: Shiny gadget for editinging compensatory pnodes

View source: R/shinyNode.R

RegressionGadgetR Documentation

Shiny gadget for editinging compensatory 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

MakeRegressionGadget(pnode, useR2 = PnodeNumParents(pnode) > 0L,
color = "sienna")
RegressionGadget(pnode, useR2 = PnodeNumParents(pnode) > 0L,
color="sienna",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.

useR2

A logical value. If true, the link scale parameter is convered to an R^2 parameter in the gadget.

viewer

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

Details

The RegressionGadget assumes that:

  • The link function is normalLink.

  • There is a single rule for all states, and that rule is Compensatory.

  • There is no inner Q-matrix, i.e., PnodeQ(pnode)=TRUE.

  • There is a single beta value.

  • That PnodeLinkScale(pnode) has a positive value.

This model is essentially a latent regression of the effective thetas onto the latent theta of the child space. The link scale parameter gives the residual variance (see normalLink).

An alternative parameterization, often more familiar to experts, uses the multiple R^2 instead of the residual variance. The useR2 flag determines how the link scale parameter is conveyed on the gadget.

Value

The function MakeRegressionGadget 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 RegressionGadget 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

OffsetGadget, CompensatoryGadget, 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))

## RegressionGadget

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="Compensatory", link="normalLink")
PnodePriorWeight(partial3) <- 10
PnodeLinkScale(partial3) <- 1.0
BuildTable(partial3)

partial3 <- RegressionGadget(partial3)
partial3 <- RegressionGadget(partial3,useR2=FALSE)

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

## No parent case
theta2 <- Pnode(theta2,link="normalLink",linkScale=1)
theta2 <- RegressionGadget(theta2)


DeleteNetwork(tNet)
stopSession(sess)

## End(Not run)


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