Displaying 20 results from an estimated 4000 matches similar to: "rmultinomial() function"
2010 Nov 18
1
dmultinomial
Hello All,
I'm trying to run a maximum likelihood analysis using dmultinomial (i'm
avoiding dmultinom as I'd like to run it with vectors for the ML stuff).
However, I'm having a hard time getting even the simplest example
running. Any help would be greatly appreciated.
> library(mc2d)
> dmultinomial(x=c(0,0,1),prob=c(1,1,1),size=1,log=TRUE)
Error in if (ncol(x) != K)
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
2008 Feb 08
2
R version of SAS Proc Varclus
I am interested in finding an R version of SAS "Proc Varclus". SAS's Proc Varclus implements an oblique cluster analysis based on principal components. How can I find out if R has a package that runs the same algorithm implemented in SAS "Proc Varclus"?
Thank you,
Mary Helen Black
__________________________
Mary Helen Black, M.S.
Keck School of Medicine of USC
2006 Jan 20
3
Troubles with the function rmultinom.c of the R's Random Number Generator
Hi,
I'm simulating a Markov chain in Fortran interfaced with R-2.2.1 in order
to generate data according to a Markov Random Field called the Potts model.
R Version:
platform i686-pc-linux-gnu
arch i686
os linux-gnu
system i686, linux-gnu
status
major 2
minor 2.1
year 2005
month 12
day 20
svn rev 36812
Each loop of my Fortran calls the function rmultinom.c
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
>>>>> Christophe Dutang
>>>>> on Sat, 8 Apr 2023 14:21:53 +0200 writes:
> Dear all,
> Using rmultinom() in a stochastic model, I found this function returns an error message 'NA in probability' for an infinite probability.
> Maybe, a more precise message will be helpful when debugging.
>> rmultinom(1, 3:5, c(1/2, 1/3,
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
On 08/04/2023 5:53 p.m., Martin Maechler wrote:
>>>>>> Christophe Dutang
>>>>>> on Sat, 8 Apr 2023 14:21:53 +0200 writes:
>
> > Dear all,
>
> > Using rmultinom() in a stochastic model, I found this function returns an error message 'NA in probability' for an infinite probability.
>
> > Maybe, a more
2023 Apr 08
1
Error message for infinite probability parameters in rbinom() and rmultinom()
Dear all,
Using rmultinom() in a stochastic model, I found this function returns an error message 'NA in probability' for an infinite probability.
Maybe, a more precise message will be helpful when debugging.
> rmultinom(1, 3:5, c(1/2, 1/3, Inf))
Error in rmultinom(1, 3:5, c(1/2, 1/3, Inf)) : NA in probability vector
> rmultinom(1, 3:5, c(1/2, 1/3, NA))
Error in rmultinom(1,
2016 Mar 10
3
rmultinom.c error probability not sum to 1
Hi all,
I should have given a better explanation of my problem. Here it is.
I extracted from my code the bit that gives the error. Place this in a file called test.c
#include <math.h>
#include <R.h>
#include <Rmath.h>
#include <float.h>
#include <R_ext/Print.h>
int main(){
double prob[3] = {0.0, 0.0, 0.0};
double prob_tot = 0.;
prob[0] = 0.3*dnorm(2, 0,
2010 Sep 08
11
problem with outer
Hello,
i wrote this function guete and now i want to plot it: but i get this error
message. i hope someone can help me.
Error in dim(robj) <- c(dX, dY) :
dims [product 16] do not match the length of object [1]
p_11=seq(0,0.3,0.1)
p_12=seq(0.1,0.4,0.1)
guete = function(p_11,p_12) {
set.seed(1000)
S_vek=matrix(0,nrow=N,ncol=1)
for(i in 1:N) {
X_0=rmultinom(q-1,size=1,prob=p_0)
2016 Mar 10
2
rmultinom.c error probability not sum to 1
Dear all,
I have a questions regarding using the c function rmultinom.c.
I got the following error message "rbinom: probability sum should be 1, but is 0.999264"
Which is thrown by:
if(fabs((double)(p_tot - 1.)) > 1e-7)
MATHLIB_ERROR(_("rbinom: probability sum should be 1, but is %g"),
(double) p_tot);
I understand my probabilities do not sum to one close enough. I
2008 Mar 05
1
Question on "assign(paste.."
Hello,
I'm having trouble in using "assign(paste ..." command . I could create
several dataframes following trinomial distribution using it but it could
not be used to check their row means of the created dataframe.
For example, the following works:
probTrt=matrix(0,4,3);
probTrt;
#malf, death, normal
probTrt[1,]=c(0.064,0.119,0.817);#for Trt 1
probTrt[2,]=c(0.053,0.125,0.823);#for
2006 Dec 09
1
Error in rmultinom(n, size, prob) : too few positive probabilities
// R 2.3.1
Can someone please explain why this error returns?
> y=numeric(100)
> x=matrix(runif(16),4,4)
> for(i in 2:100)
+ {
+ y[i]=which(rmultinom(1, size = 1, prob = x[y[i-1], ])==1)
+ }
Error in rmultinom(n, size, prob) : too few positive probabilities
thx much
ej
2010 Nov 08
7
How to rbind list of vectors with unequal vector lengths?
Hi,
How to rbind these vectors from a list?:
> l <- list(a = c(1, 2), b = c(1, 2, 3))
> l
$a
[1] 1 2
$b
[1] 1 2 3
> do.call(rbind, l)
[,1] [,2] [,3]
a 1 2 1
b 1 2 3
Warning message:
In function (..., deparse.level = 1) :
number of columns of result is not a multiple of vector length (arg 1)
>
-J
2007 Mar 30
1
faster computation of cumulative multinomial distribution
Dear list members,
I have a series of /unequal/ probabilities [p1,p2,...,pk], describing
mutually exclusive events, and a "remainder" class with a probability
p0=1-p1-p2-....-pk, and need to calculate, for a given number of trials
t>=k, the combined probability that each of the classes 1...k contains
at least 1 "event" (the remainder class may be empty).
To me this reaks
2008 May 16
2
Integer / floating point question
Dear R-help -
I have thought about this question for a bit, and come up with no
satisfactory answer.
Say I have the numeric vector t1, given as
t1 <- c(1.0, 1.5, 2.0, 2.5, 3.0)
I simply want to reliably extract the unique integers from t1, i.e., the
vector c(1, 2, 3). This is of course superficially simple to carry out.
However, my question is related to R FAQ 7.31, "Why
2011 Nov 07
3
Sampling with conditions
Hey everyone,
I am at best, an amateur user of R, but I am stuck on how to set-up the
following situation.
I am trying to select a random sample of numbers from 0 to 10 and insert
them into the first column of a matrix (which will used later in a loop).
However, I need to have those numbers add up to 10. How can I set those
conditions?
So far I have:
n<-matrix(0,nr=5,ncol=10)
for(i in
2009 Aug 31
4
Offtopic, HT vs. HH in coin flips
Dear R-help,
Could someone please try to explain this paradox to me? What is more likely to show up first in a string of coin tosses, "Heads then Tails", or "Heads then Heads"?
##generate 2500 strings of random coin flips
ht <- replicate(2500,
paste(sample(c("H", "T"), 100, replace = TRUE),
collapse =
2008 Jul 02
1
Hmisc latex function with longtable option
Hello -
I'm trying to use Hmisc's latex function to produce a postscript file of
a data.frame, using the longtable = TRUE option. When I run, for example,
## sample R code
dvips(latex(data.frame(a = rnorm(100), b = rnorm(100)),
longtable = TRUE), file = "test.ps")
latex runs successfully and a test.ps file is produced. However, I see
the following in the
2010 May 23
4
creating a reverse geometric sequence
Hello,
Can anyone think of a non-iterative way to generate a decreasing geometric
sequence in R?
For example, for a hypothetical function dg, I would like:
> dg(20)
[1] 20 10 5 2 1
where I am using integer division by 2 to get each subsequent value in the
sequence.
There is of course:
dg <- function(x) {
res <- integer()
while(x >= 1) {
res <- c(res, x)
x
2012 Jun 28
2
R help, using R to build choropleth
Hi guys
i need some help to build choropleth.
Basically i am trying to colour regions on the map by population.
I possess the shape file of the country, and also the population data,
however, i am having trouble to create the plot, below is my code:
population=read.csv("nz2.csv")
population
names(population)
nz=readShapeSpatial((sprintf('nz-geodetic-marks',tmp_dir)))