Displaying 20 results from an estimated 67 matches for "dnbinom".
Did you mean:
dbinom
2007 Oct 23
1
How to avoid the NaN errors in dnbinom?
Hi, The code below is giving me this error message:
Error in while (err > eps) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In dnbinom(x, size, prob, log) : NaNs produced
2: In dnbinom(x, size, prob, log) : NaNs produced
I know from the help files that for dnbinom "Invalid size or prob will
result in return value NaN, with a warning", but I am not able to find a
workaround for this in my code to avoid it. I appreciate t...
2009 Apr 13
1
dnbinom with a large size parameter (PR#13650)
Full_Name: Andrey Pavlov
Version: 2.7.1 (2008-06-23)
OS: Windows Vista
Submission from: (NULL) (67.193.233.43)
Dear developers,
I discovered an issue with the dnbinom function while fitting a negative
binomial model to my data. I was using the size and mu parameterization. When
the size gets large enough, the function begins to return 1, while it should
instead return the respective Poisson probability. This can be seen in the
following simple example:
> dpo...
2001 Feb 08
2
dnbinom(,size<1,)=0 (PR#842)
This came up on r-help but indicates a bug.
dnbinom(x,n,p) calls dbinom_raw(n-1,...)
which returns 0 for n<1.
-thomas
---------- Forwarded message ----------
Date: Thu, 08 Feb 2001 17:10:23 +0000
From: Yudi Pawitan <yudi@stat.ucc.ie>
To: Mark Myatt <mark@myatt.demon.co.uk>
Cc: R-Help <r-help@stat.math.ethz.ch>
Subject: Re: [...
2008 Jul 04
1
update on dnbinom with large "size"
...be easy enough
to test and return NA under these circumstances?
function (x, size, prob, mu, log = FALSE)
{
~ if (!missing(mu)) {
~ if (!missing(prob))
~ stop("'prob' and 'mu' both specified")
~ prob <- size/(size + mu)
~ }
~ .Internal(dnbinom(x, size, prob, log))
}
~ Ben Bolker
- --------------------------
~ Check it out:
curve(dnbinom(1,mu=0.5,size=x),log="x",from=1,to=1e18)
abline(h=dpois(1,lambda=0.5),col=2,lty=2)
text(1,dpois(1,lambda=0.5)+0.02,"Poisson",col=2,pos=4)
~ I will take a look in the C code whe...
2008 Apr 18
2
rzinb (VGAM) and dnbinom in optim
...nging my head against the keyboard for too long now, hopefully someone can pick up on the errors of my ways...
I am trying to use optim to fit a zero-inflated negative binomial distribution. No matter what I try I can't get optim to recognize my initial parameters. I think the problem is that dnbinom allows either 'prob' or 'mu' and I am trying to pass it 'mu'. I've tried a wrapper function but it still hangs. An example:
#set up dummy data,load VGAM, which is where I am getting the zero-inflated neg binom
#I get the same problem without VGAM, using dnbinom in the...
2001 Feb 09
0
Re: [Rd] dnbinom(,size<1,)=0 (PR#842)
my current code for dnbinom.c has
prob = dbinom_raw(n,x+n,p,1-p,give_log);
f = ((double)n)/((double)(n+x));
return((give_log) ? log(f) + prob : f*prob);
which should work for x>=0, n>=0, 0<=p<=1.
dbinom.raw(x,n,p) is intended to work for x>=0, n>=0, 0<=p<=1,
without integer checks. When necessar...
2009 Aug 31
2
interactions and stall or memory shortage
...nteractions, when I try to evaluate two pairs of interactions(
flowers*gopher, flowers*rockiness) my computer runs out of memory, and the
larger desktop I use just doesn't go anywhere after about 20 minutes.
Is it really that big a calculation?
to start:
mle2(minuslogl = Lily_sum$seedlings ~ dnbinom(mu = a, size = k),
start = list(a = 10, k = 1))
then:
i2<-interaction(Lily_sum$flowers, Lily_sum$gopher)
i3<-interaction(Lily_sum$flowers, Lily_sum$rockiness)
mle2(Lily_sum$seedlings ~ dnbinom(mu = a, size = k), start=list(a=10,k=1)
,parameters=list(a~i3+i2+Lily_sum$flowers))
(the last ru...
2017 Oct 02
2
Help on adding a negative binomial density plot
...ing the number of particles.
I first fit a negative binomial model using
> nbFit<-glmer.nb(Count ~ Cleaning + (1|Sampling_point) , data = myCountDB)
I now would like to add a curve to the histogram representing the negative binomial density function fitted to my data using
> curve(dnbinom(x=, size=, prob=, mu=), add=TRUE)
But I am struggling defining the arguments to dnbinom.
Using the str() function on the nbFit object I see there are many fields returned. And I get lost reading the ?glmer.nb help, greatly because of my lack of knowledge. Which ones should I use?
Thanks ever...
2008 Dec 03
1
nlminb: names of parameter vector not passed to objective function
...rsion 2.9.0 Under development (unstable) (2008-12-03 r47039)
i386-pc-mingw32
Thanks a lot
Thomas Petzoldt
set.seed(3577) # make it reproducible
## 1) example taken from ?nlminb -------------------------------------
x <- rnbinom(100, mu = 10, size = 10)
hdev <- function(par) {
-sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE))
}
nlminb(c(20, 20), hdev, lower = 0.001, upper = Inf)
## --> works without problems
## 2) same example, but with named vectors -----------------------------
hdev <- function(par) {
cat(names(par), "\n") # show what happens
-sum...
2011 Apr 04
1
Clarks 2Dt function in R
Dear Ben,
you answerd to Nancy Shackelford about Clarks 2Dt function.
Since the thread ended just after your reply,
I would like to ask, if you have an idea how to use this function in R
I defined it the following way:
function(x , p, u) {
(p/(pi*u))*(1+(x^2/u))^(p+1)
}
and would like to fit this one to my obeservational data (count)
[,1] [,2]
[1,] 15 12
[2,] 45 13
[3,]
2017 Oct 02
0
Help on adding a negative binomial density plot
...ative binomial model using
>
>
>> nbFit<-glmer.nb(Count ~ Cleaning + (1|Sampling_point) , data = myCountDB)
>
>
>
> I now would like to add a curve to the histogram representing the negative binomial density function fitted to my data using
>
>
>> curve(dnbinom(x=, size=, prob=, mu=), add=TRUE)
Why not use the predict function in that package?
See ?merMod
--
David.
>
>
> But I am struggling defining the arguments to dnbinom.
>
>
> Using the str() function on the nbFit object I see there are many fields returned. And I get lost re...
2001 Feb 07
3
Goodness of fit to Poisson / NegBinomial
All,
I have some data on parasites on apple leaves and want to do a
goodness of fit test to a Poisson distribution. This seems to
do it:
mites <- c(rep(0,70),
rep(1,38),
rep(2,17),
rep(3,10),
rep(4,9),
rep(5,3),
rep(6,2),
rep(7,1))
tab <- table(mites)
NSU <- length(mites)
N <-
2003 Feb 01
1
Trouble with optim
...e: x86
release: NT 5.0
R.Version() tells me:
platform: i386-pc-mingw32
arch: i386
os: mingw32
system: i386, mingw32
status:
R.version.string: R version 1.6.2, 2003-01-10
My full code is here:
dnegbinp <- function(x,prob,mu,size,log=FALSE) {
ll <- ifelse(x==0,
log(1-prob+prob*dnbinom(0*x,mu=mu,size=size)),
log(prob)+dnbinom(x,mu=mu,size=size,log=TRUE));
if (log) ll else exp(ll);
}
x <- c(1,3,0,19,32,0,0,2,23,23)
loglikfun <- function(p) {
cat("Eval fn at ")
cat(p)
s <- -sum(dnegbinp(x, prob=p[[1]],mu=p[[2]],size=p[[3]], log=TRUE))...
2017 Oct 03
1
Help on adding a negative binomial density plot
...t a negative binomial model using
>
>
>> nbFit<-glmer.nb(Count ~ Cleaning + (1|Sampling_point) , data = myCountDB)
>
>
>
> I now would like to add a curve to the histogram representing the negative binomial density function fitted to my data using
>
>
>> curve(dnbinom(x=, size=, prob=, mu=), add=TRUE)
Why not use the predict function in that package?
See ?merMod
--
David.
>
>
> But I am struggling defining the arguments to dnbinom.
>
>
> Using the str() function on the nbFit object I see there are many fields returned. And I get lost reading...
2013 Apr 06
1
Plotting a curve for a Holling Type III Functional Response
Hey,
So I have a scatter plot and I am trying to plot a curve to fit the data
based on a Holling Type III functional response. My function is this:
nll2<-function(a,b) {
conefun<-(a*DBH^2)/(b^2+DBH^2)
nlls2<-dnbinom(x=cones ,size=DBH, mu=conefun,log=TRUE)
-sum(nlls)
}
and my plot is this:
plot (DBH,cones)
DBH is on the x-axis and cones is on the y-axis. How do I get the curve for
my function onto the scatterplot?
--
View this message in context: http://r.789695.n4.nabble.com/Plotting-a-curve-for-a-Hol...
2012 Jul 04
2
About nlminb function
Hello
I want to use the nlminb function but I have the objective function like
characters. I can summarize the problem using the first example in the
nlminb documentation.
x <- rnbinom(100, mu = 10, size = 10)
hdev <- function(par) -sum(dnbinom(x, mu = par[1], size = par[2], log =
TRUE))
nlminb(c(9, 12), objective=hdev)
With the last instructions we obtain appropriate results. If I have the name
of the objective function stored in the element name, how can modify the
next two instructions to obtain the same above results?
name <- ...
2008 Sep 25
0
Please help me interpret these results (fitting distributions to real data)
...es")= chr "lambda"
$ sd : Named num 0.213
..- attr(*, "names")= chr "lambda"
$ n : int 337
$ loglik : num -2721
- attr(*, "class")= chr "fitdistr"
> nb15 = fitdistr(x15,"negative binomial")
Warning messages:
1: In dnbinom(x, size, prob, log) : NaNs produced
2: In dnbinom(x, size, prob, log) : NaNs produced
3: In dnbinom(x, size, prob, log) : NaNs produced
> str(nb15)
List of 4
$ estimate: Named num [1:2] 0.973 15.309
..- attr(*, "names")= chr [1:2] "size" "mu"
$ sd : Named...
2008 Jul 03
2
what can we do when R gives no response
...i386-apple-darwin8.10.1
locale:
zh_CN.UTF-8/zh_CN.UTF-8/C/C/zh_CN.UTF-8/zh_CN.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mclust_3.1-5
x <- rnbinom(100, mu = 10, size = 10)
hdev <- function(par) {
-sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE))
}
nlminb(c(9, 12), hdev)
-----------------------------------------------
Peng Jiang 江鹏 ,Ph.D. Candidate
Antai College of Economics & Management
安泰经济管理学院
Department of Mathematics
数学系
Shanghai Jiaotong University (Minhang Campus)
800 Dongchuan Road
200...
2006 Mar 22
4
pbinom( ) function (PR#8700)
Full_Name: Chanseok Park
Version: R 2.2.1
OS: RedHat EL4
Submission from: (NULL) (130.127.112.89)
pbinom(any negative value, size, prob) should be zero.
But I got the following results.
I mean, if a negative value is close to zero, then pbinom() calculate
pbinom(0, size, prob). dbinom() also behaves similarly.
> pbinom( -2.220446e-22, 3,.1)
[1] 0.729
> pbinom( -2.220446e-8, 3,.1)
2008 Aug 21
1
pnmath compilation failure; dylib issue?
...erpad_max_install_names -mmacosx-version-min=10.4 -undefined
dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/
lib -o pnmath.so bd0.o beta.o chebyshev.o choose.o d1mach.o dbeta.o
dbinom.o dcauchy.o dchisq.o dexp.o df.o dgamma.o dgeom.o dhyper.o
dlnorm.o dlogis.o dnbeta.o dnbinom.o dnchisq.o dnf.o dnorm.o dnt.o
dpois.o dt.o dunif.o dweibull.o fmax2.o fmin2.o ftrunc.o gamma.o
gamma_cody.o i1mach.o imax2.o imin2.o lbeta.o lgamma.o lgammacor.o
mlutils.o pbeta.o pbinom.o pcauchy.o pchisq.o pexp.o pf.o pgamma.o
pgeom.o phyper.o plnorm.o plogis.o pnbeta.o pnbinom.o pnchis...