search for: rmulti

Displaying 3 results from an estimated 3 matches for "rmulti".

Did you mean: multi
2000 Sep 20
1
SV: sample from contingency table
I have had the same problem and I wrote this function rmulti <- function(n, size, p) { NrDim <- length(p) if(NrDim<2) stop("The simulated variabel has to be at least 2-dimensional") res <- matrix(data=NA, nrow=n, ncol=NrDim) p <- p/sum(p) TempSize <- size for(i in 1:NrDim) { TempP <- p[i]/sum(p[i:NrDim]) T...
2001 Apr 09
4
fastest R platform
...rm(list=ls(all=TRUE)) ###small and common functions################################## glmm.sample.y <- function(x, z, b, D.u) { pp <- matrix(0, nrow = m, ncol = n); D.u.half <- t( chol(D.u) ); zero <- numeric(n.random); for(i in 1:m) { obj <- rmulti.norm(zero, D.u.half); pp[i, ] <- as.vector( x[i, , ] %*% b + z[i, , ] %*% obj$ran ); } pp <- exp(pp)/( 1+exp(pp) ); y <- runif(m*n); dim(y) <- c(m, n); ifelse(y < pp, 1, 0); #returning vector } ################ rmulti.norm &l...
2001 Apr 17
1
fastest R platform: follow-up and summary
...ecl mu = zeros(4,1); decl var_root = unit(4); for(i=0; i<N; i++) { ran = multi_normal(mu, var_root); sum = sum + ran*ran'; } sum = sum/N; print(sum); print(time()); } R-program ################ rm(list=ls(all=TRUE)); rmulti.norm <- function(mean, var.root) { ran <- rnorm(4); ran <- mean + as.vector( var.root %*% ran ); } main <- function() { N <- 1000000; sum <- numeric(4); print(date()); mu <- numeric(4); var.root <- matrix(0, 4, 4);...