File: cwdeviance.r

package info (click to toggle)
r-cran-erm 1.0-6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,952 kB
  • sloc: f90: 401; ansic: 103; makefile: 8
file content (16 lines) | stat: -rwxr-xr-x 553 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cwdeviance <- function(object, pi.hat)
{
# computes casewise deviance for objects of class ppar

  X <- object$X.ex
  loglik.full <- sum(X*log(pi.hat)+(1-X)*log(1-pi.hat), na.rm = TRUE)  #for ordinary logistic regression
  npar.full <- (dim(object$W)[2])+sum(object$npar)           #number of estimated item + person parameters
  npar.sat <- sum(nrow(pi.hat)*ncol(pi.hat))

  value <- -2*loglik.full
  df <- npar.sat-npar.full
  p.value <- 1-pchisq(value, df = df)
  
  result <- list(value = value, df = df, p.value = p.value)
  result
}