search for: rmultinomial

Displaying 6 results from an estimated 6 matches for "rmultinomial".

Did you mean: multinomial
2008 Mar 18
2
rmultinomial() function
After scouring the online R resources and help pages, I still need clarification on the function rmultinomial(). I would like to create a vector, say of 100 elements, where every element in the vector can take on the value of 0, 1 or 2, and where each of those values have a specific probability. ie. the probability a given element in the vector = 0 is 0.06, 1 = 0.38, 2 = 0.56 (probabilities sum to 1). Can...
2010 Nov 18
1
dmultinomial
...multinomial(x=c(0,0,1),prob=c(1,1,1),size=1,log=TRUE) Error in if (ncol(x) != K) stop("x[] and prob[] must be equal length vectors or equal col matrix.") : argument is of length zero # Once I get the simple stuff above running, I'd like to be able to do the following: > testmat=rmultinomial(4, 1, prob) > testmat [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 0 1 [3,] 0 0 1 [4,] 0 0 1 > dmultinomial(x=testmat,prob=prob,size=1,log=TRUE) Error in if (!is.null(size) && nrow(size) != n) size <- matrix(t(size), : missing value where TRUE/FALSE...
2010 Mar 24
1
with data in the form of an R data objecte: Monte Carlo simulation in R
Hi, please use the following the matrix z as the example: x<-c(2,4,5,7,6,9,8,2,0) y<-matrix(x,3,3) z<-apply(y,2,function(x)x/sum(x)) z On Tue, Mar 23, 2010 at 6:59 PM, David Winsemius <dwinsemius@comcast.net>wrote: > > On Mar 23, 2010, at 9:05 PM, Hongwei Dong wrote: > > Hi, R-helpers, >> >> I'm trying to use R to do a Monte Carlo simulation and
2012 Aug 17
0
install.packages umask configuration
...package ?combinat? finding HTML links ... done combn html dmnom html hcube html nsimplex html permn html rmultinomial html x2u html xsimplex html ** building package indices ** testing if installed package can be loaded * DONE (combinat) The downloaded source packages are in ?/tmp/RtmpYRQ6Gh/downloaded_packages...
2012 Oct 05
2
problem with convergence in mle2/optim function
...ncol = 3)) } pdat <- sapply(tv, psim, simplify = TRUE) Pdat <- as.data.frame(t(pdat)) names(Pdat) <- c("time", "P1", "P2", "P3") # Generate simulated data set from probabilities n = rep(20, length(tv)) p = as.matrix(Pdat[,2:4]) y <- as.data.frame(rmultinomial(n,p)) yt <- cbind(tv, y) names(yt) <- c("tv", "n1", "n2", "n3") # mle2 call mle.fit <- mle2(NLL.func, data = list(y = yt), start = list(p1 = p1t, p2 = p2t, mu1 = mu1t, mu2 = mu2t), control = list(maxit = 5000, factr...
2012 Sep 27
0
problems with mle2 convergence and with writing gradient function
...3)) } pdat <- sapply(tv, psim, simplify = TRUE) Pdat <- as.data.frame(t(pdat)) names(Pdat) <- c("time", "P1", "P2", "P3") # Generate simulated data set from model probabilities n = rep(20, length(tv)) p = as.matrix(Pdat[,2:4]) y <- as.data.frame(rmultinomial(n,p)) yt <- cbind(tv, y) names(yt) <- c("tv", "n1", "n2", "n3") # mle2 call mle.fit <- mle2(NLL.func, data = list(y = yt), start = list(p1 = p1t, p2 = p2t, mu1 = mu1t, mu2 = mu2t), control = list(maxit = 5000, lmm =...