Displaying 20 results from an estimated 700 matches similar to: "faster computation of cumulative multinomial distribution"
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)
2009 Nov 04
1
compute maximum likelihood estimator for a multinomial function
Hi there
I am trying to learn how to compute mle in R for a multinomial negative
log likelihood function.
I am using for this the book by B. Bolker "Ecological models and data in
R", chapter 6: "Likelihood an all that". But he has no example for
multinomial functions.
What I did is the following:
I first defined a function for the negative log likelihood:
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
2008 Feb 08
0
Cumulative multinomial regression using VGAM
Hi,
I am trying to carry out a multinomial regression using the cumlogit link function. I have tried using the VGAM package, and have gotten some results...
fit1 <- vgam(Y ~ X1 + X2 + X3 + X4,
cumulative(link=logit,intercept.apply=FALSE,parallel=TRUE),
data = data1
)
The problem arrises when I try to get the information out of the fitted object. I can
2010 Feb 12
1
using mle2 for multinomial model optimization
Hi there
I'm trying to find the mle fo a multinomial model ->*L(N,h,S?x)*. There
is only *N* I want to estimate, which is used in the number of successes
for the last cell probability. These successes are given by:
p^(N-x1-x2-...xi)
All the other parameters (i.e. h and S) I know from somewhere else.
Here is what I've tried to do so far for a imaginary data set:
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
2011 Apr 15
1
How to generate a correlation matrix with restrictions on its eigenvalues
Dear All,
I would like to generate m positive real numbers c_i, I=1,...,m, such that
(1) c_1 + c_2 + ... + c_m=m,
(1) after being ordered into c_1 >= c_2 >= .... >=c_m>0, we have that c_m is of the same order of m^(-1/8), when m is sufficiently large.
Thanks,
-Chee
[[alternative HTML version deleted]]
2014 Oct 19
2
Matrices complejas
Saludos compañeros/as.
Consideren una matriz de n columnas y n filas.
Quiero distribuir aleatoriamente 6 números predefinidos
(11,12,13,21,22,23,31,32,33,41,42,43), con una probabilidad de aparición de
cada número que será igual a la frecuencia de ese número dividida por la
frecuencia total de todos los números.
Soy incapaz de resolver el problema: con la función rbinom sólo puedo
generar dos
2009 Sep 21
2
Four concurrent Markov chains
Hi,
I am trying to write a simulation of the movements of four animals between
six patches. The movement between patches is based on a first-order Markov
chain so that the next patch they visit depends on the patch they were in
before.
I have written code that allows me to simulate the movement of one animal
but when I add more there seems to be a problem and all chains come back as
N/A. I can
2009 Aug 30
1
Stochastic (transition) matrices: how to determine distributions and variance?
(apologies for the cross-posting, and for this being a more general
stats question rather than a specific-to-R one. I assure you I will be
doing the actual analysis in R :)
I am trying to determine the distribution and variance for a classic
stochastic (transition) matrix problem such that:
let x(t) be an initial state vector consisting of counts of classes A, B
and C:
x(t) =
2005 Oct 03
6
sampling vectors
Hello Listers,
I am trying to sample a vector to create a new one of sample length,
witha sum equal to the sum of the initial vector:
initial = 10, 30, 10 (sum=50)
sample example = 5, 35, 10 (sum=50) or 25, 15, 10 (sum=50), etc ...
My problem is to control the sum, so it stays constant.
Any suggestions would be very helpful !
Thank you in advance,
Eric
2003 Jan 27
1
rmultinom() -- how \\ via own C code?
I've had a need for multinomial "random number generation"
occasionally. And other people too.
The following code is currently in the
(very small ``not very high importance'') CRAN package normix
--- which I will rename to "nor1mix" very seen because of a
``name registration'' problem
I want to add "this" (well the functionality) to a
2007 Apr 16
1
My First Function: cryptic error message
Dear List,
My first R function is a rip-off bagging algorithm from pg. 138 of
Everitt and Hothorn's "Handbook of Statistical Analyses using R"
(HSAUR). I'm using recursive partitioning to develop a set of useful
variables in diagnosing ADHD.
I'm running this in ESS in XEmacs 21.4.19, R 2.4.1 on Slackware Linux
11.0 with a 2.6 kernel.
This is almost an entire script,