File: plist.internal.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 (20 lines) | stat: -rwxr-xr-x 814 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# computes a list of expected probabilities for objects of class Rm
# with 0th category included!
plist.internal <- function(object, theta){

  X <- object$X
  mt_vek <- apply(X, 2L, max, na.rm = TRUE)   # number of categories - 1 for each item
  mt_ind <- rep(seq_along(mt_vek), mt_vek)

  #--------compute list matrix of probabilites for fixed theta)
  p.list <- tapply(object$betapar, mt_ind, function(beta.i){
              beta.i <- c(0, beta.i)
              ind.h <- 0:(length(beta.i)-1)
              theta.h <- tcrossprod(ind.h, theta) # ind.h %*% t(theta) # multiply category with 
              tb <- exp(theta.h + beta.i)
              denom <- colSums(tb)
              pi.mat <- apply(tb, 1L, function(y){ y/denom })
              return(pi.mat)
            })
  return(p.list)
}