calcDSllike: Calculates the log-likelihood for data from a...

calcDSllikeR Documentation

Calculates the log-likelihood for data from a DiBello–Samejima (Normal) distribution

Description

These functions take data which represent draws from a categorical data with the given DiBello–Samejima distribution and returns the log-likelihood of the given data.

Usage

calcDSllike(data, parents, skillLevels, child, obsLevels,
            lnAlphas, beta, dinc = 0, rule = "Compensatory")
calcDNllike(data, parents, skillLevels, child, obsLevels, 
            lnAlphas, beta, std, rule = "Compensatory") 

Arguments

data

A data frame whose columns contain variables corresponding to parent and child.

parents

A vector of names for the columns in data corresponding to the parent variables.

child

The name of the child variable, should refer to a column in data.

skillLevels

A list of character vectors giving names of levels for each of the condition variables.

obsLevels

A character vector giving names of levels for the output variables from highest to lowest.

lnAlphas

A vector of log slope parameters. Its length should be either 1 or the length of skillLevels, depending on the choice of rule.

beta

A vector of difficulty (-intercept) parameters. Its length should be either 1 or the length of skillLevels, depending on the choice of rule.

dinc

Vector of difficulty increment parameters (see calcDSTable).

rule

Function for computing effective theta (see calcDSTable).

std

The log of the residual standard deviation (see Details).

Details

This function assumes that the observed data are independent draws from a Bayesian network. This function calculates the log-likelihood of a single conditional probability table. First, it calculates a table of counts corresponding states of the parent and child variables using the function dataTable. Next it calculates the conditional probability for each cell using the function calcDSTable or calcDNTable.

It then calculates the log-likelihood as the sum of count(cell)*log(Pr(cell)) where this value is set to zero if count(cell) is zero (this allows cells with zero probability as long as the count is also zero).

Value

A real giving the log-likelihood of the observed data.

Note

This function is primarily about testing the log likelihood calculations used internally in StatShop.

This function is largely superceeded by the likelihood calculation internal to mapDPC. In particular, if probs is the result of the call to calcDPCTable, and postTable is the expected contingency table (e.g., the output of expTable). Then the log likelihood is -2*sum(as.vector(postTable)*as.vector(log(probs))).

Author(s)

Russell Almond

References

http://comet.research.ets.org/~ralmond/StatShop

See Also

dataTable, calcDSTable, Compensatory,OffsetConjunctive, eThetaFrame, calcDNTable

Examples

  skill1l <- c("High","Medium","Low") 
  skill3l <- c("High","Better","Medium","Worse","Low") 
  correctL <- c("Correct","Incorrect") 

  x <- read.csv(system.file("testFiles", "randomPinned100.csv", 
                package="CPTtools"),
              header=TRUE, as.is=TRUE)
  x[,"Skill1"] <- ordered(x[,"Skill1"],skill1l)
  x[,"Skill3"] <- ordered(x[,"Skill3"],skill3l)
  x[,"Comp.Correct"] <- ordered(x[,"Comp.Correct"],correctL)


  like <- calcDSllike(x,c("Skill1","Skill3"),
                      list(Skill1=skill1l, Skill3=skill3l),
                      "Comp.Correct", correctL,
                      log(c(0.45,-0.4)),-1.9,rule="Compensatory")
  


ralmond/CPTtools documentation built on Dec. 27, 2024, 7:15 a.m.