R/simR.R

Defines functions simR

Documented in simR

# simulates rankings data with given worth
#
simR<-function(nobj, nobs, worth=NULL, seed=NULL, pr=FALSE)
{
   if(nobj>10)
     stop("nobj too large!")
   if(!is.null(seed)) set.seed(seed)

   if(is.null(worth)){
       worth<-runif(nobj)
   } else if(length(worth)!=nobj)
       stop("length of worth is not equal to nobj\n")
   worth<-worth/sum(worth)
   if (pr)
     cat("used worth parameters are: ", worth, "\n")

   P<-permutations(nobj)

   R<-nobj-P              # following Critchlow & Fligner
   patt<-R%*%log(worth)

   p<-exp(patt)/sum(exp(patt))


   vecF<-rmultinom(1,nobs, p)
   simdat<-expand.mat(P,vecF)
   data.frame(simdat)
}

Try the prefmod package in your browser

Any scripts or data that you put into this service are public.

prefmod documentation built on Sept. 30, 2023, 5:06 p.m.