From: Doran, Harold <HDoran_at_air.org>

Date: Thu 20 Jul 2006 - 06:09:04 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu Jul 20 06:15:37 2006

Date: Thu 20 Jul 2006 - 06:09:04 EST

# define functions

pcm <- function(theta,d,score){

exp(rowSums(outer(theta,d[1:score],'-')))/ apply(exp(apply(outer(theta,d, '-'), 1, cumsum)), 2, sum)}

foo <- function(theta,items, score){

like.mat <- matrix(numeric(length(items) * length(theta)), ncol = length(theta))

for(i in 1:length(items)) like.mat[i, ] <- pcm(theta, items[[i]], score[[i]])

}

# begin example

theta <- c(-1,-.5,0,.5,1)

items <- list(item1 = c(0,1,2), item2 = c(0,1), item3 = c(0,1,2,3,4),
item4 = c(0,1))

score <- c(2,1,3,1)

(foo(theta, items, score))

# R output from function foo

[1] 0.8807971 0.8175745 0.7310586 0.6224593 0.5000000

However, what I am expecting from the function foo is

platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 3.0 year 2006 month 04 day 24 svn rev 37909 language Rversion.string Version 2.3.0 (2006-04-24)

[[alternative HTML version deleted]]

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu Jul 20 06:15:37 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Thu 20 Jul 2006 - 10:22:16 EST.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*