Displaying 13 results from an estimated 13 matches for "rnegbin".
Did you mean:
negbin
2006 Feb 18
1
truncated negative binomial using rnegbin
Dear R users,
I'm wanting to sample from the negative binomial distribution using the
rnegbin function from the MASS library to create artificial samples for the
purpose of doing some power calculations. However, I would like to work
with samples that come from a negative binomial distribution that includes
only values greater than or equal to 1 (a truncated negative binomial), and
I c...
2004 Feb 10
1
generate random sample from ZINB
I want to generate 1,000 random samples of sample size=1,000 from ZINB.
I know there is a rnegbin() to generate random samples from NB, and I know
I can use
the following process:
do i=1 to 1000
n=0
do i=1 to 1000
if runi(1)>0.1 then x(i) = 0; else
x(i)=rnegbin();
n=n+1;
if n>1000 then stop;
end;
output;
end;
Anybody can help me out with the R code?
Thanks very much ahead of tim...
2011 May 04
1
hurdle, simulated power
...### mean function logit model
p0 <- exp(alpha0 + alpha1*trt)/(1 + exp(alpha0 + alpha1*trt))
### 0 / 1 based on p0
y1 <- as.numeric(runif(n)>p0)
### mean function count portion
mu <- exp(beta0 + beta1*trt)
### estimate counts using NB dist
require(MASS, quietly = TRUE)
y2 <- rnegbin(n, mu = mu, theta = theta)
### if y2 = 0, draw new value
while(sum(y2==0)>0){
y2[which(y2==0)] <- rnegbin(length(which(y2==0)), mu=mu[which(y2==0)],
theta = theta)
}
y<-y1*y2
data.frame(trt=trt,y=y)
}
#alpha0, alpha1 is the parameter for zero part
#beta0,beta1 is the parameter for...
2006 Jul 14
2
Negative Binomial: Simulation
...tionship
between the two possible parametrizations of the negative binomial and found
that for this fuction I must use:
prob = theta/(theta+mu) and size = theta
Theta, however, is not an integer. So how can size (which is the number of
successes) equal theta?
I know there is a function rnegbin which does what I want. I would still
like to raise the above question (probably a more statistical one
than R).
Thanks a lot for any comments.
Hadassa
[[alternative HTML version deleted]]
2005 Jan 25
1
Zipf random number generation
Hi,
Is there a Zipf-like distribution RNG in R?
Thanks,
Weiguang
2011 Nov 17
1
How to Fit Inflated Negative Binomial
Dear All,
I am trying to fit some data both as a negative binomial and a zero
inflated binomial.
For the first case, I have no particular problems, see the small snippet
below
library(MASS) #a basic R library
set.seed(123) #to have reproducible results
x4 <- rnegbin(500, mu = 5, theta = 4)
#Now fit and check that we get the right parameters
fd <- fitdistr(x4, "Negative Binomial")
summary(fd)
#and mu and theta are as expected
#now I add artificially some zeros
x5 <- sample(c(x4,rep(0,100)))
However, when I artificially add some zeros (case...
2005 Mar 03
1
Negative binomial regression for count data
...alysis. Is there any tutorial available?
anova.negbin
Likelihood Ratio Tests for Negative Binomial GLMs
glm.convert
Change a Negative Binomial fit to a GLM fit
glm.nb
Fit a Negative Binomial Generalized Linear Model
negative.binomial
Family function for Negative Binomial GLMs
rnegbin
Simulate Negative Binomial Variates
theta.md
Estimate theta of the Negative Binomial
gam.neg.bin
GAMs with the negative binomial distribution
dnb2
Density for negative binomial, used in mmlcr
theta.mmmod
Estimate theta of the Negative Binomial by Moments
NegBinomial
The...
2004 May 28
0
Negative binomial glm and dispersion
...the F-test was more appropriate when dispersion is estimated)?
Secondly, after a bit of muddling with the negative binomial pdf, I
concluded that, like for the Poisson, phi is actually 1. This result is
borne out by simulations. Is this correct?
# an example in R 1.81 with library(MASS)
y<-rnegbin(n=100,mu=1,theta=1)
x<-1:length(y)
model<-glm(y~x,family=neg.bin(1))
summary(model)$dispersion
[1] 1.288926
anova(model,test='Chisq")
#...
Df Deviance Resid. Df Resid. Dev P(>|Chi|)
NULL 99 102.038
x 1 0.185 98 101.853...
2005 Apr 04
1
help with kolmogorov smirnov test
What does 'with ties in' mean?
with some identical elements (par ex., au moins une paire ex-equo)
HTH
____________________
Ken Knoblauch
Inserm U371, Cerveau et Vision
Department of Cognitive Neurosciences
18 avenue du Doyen Lepine
69675 Bron cedex
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: 06 84 10 64 10
http://www.lyon.inserm.fr/371/
2010 Jan 22
1
confidence intervals for mean (GLM)
...<- with(mydata1, tapply(value, treatments, mean))
now I need the confidence intervals for the means
And then again for a negative binomial GLM
require(MASS)
mydata2 <- data.frame('treatments'=gl(4, 4, 64, LETTERS[1:4]), 'species'=gl(4, 1, 64, letters[1:4]), 'value'=rnegbin(64,1,1))
model2 <- glm.nb(value ~ treatments*species, data=mydata2)
means2 <- with(cbind('x'=gl(16,4),mydata2), tapply(value, x, mean))
Can I get the confidence intervals for each mean in means1 and means2, according to the family used?
Thanks in advance, all the best!
Rafael....
2012 Oct 19
2
MLE of negative binomial distribution parameters
I need to estimate the parameters for negative binomial distribution (pdf)
using maximun likelihood, I also need to estimate the parameter for the
Poisson by ML, which can be done by hand, but later I need to conduct a
likelihood ratio test between these two distributions and I don't know how
to start! I'm not an expert programmer in R. Please help
--
View this message in context:
2005 Mar 11
0
Negative binomial regression for count data,
...gt;
>
> anova.negbin
> Likelihood Ratio Tests for Negative Binomial GLMs
> glm.convert
> Change a Negative Binomial fit to a GLM fit
> glm.nb
> Fit a Negative Binomial Generalized Linear Model
> negative.binomial
> Family function for Negative Binomial GLMs
> rnegbin
> Simulate Negative Binomial Variates
> theta.md
> Estimate theta of the Negative Binomial
> gam.neg.bin
> GAMs with the negative binomial distribution
> dnb2
> Density for negative binomial, used in mmlcr
> theta.mmmod
> Estimate theta of the Negative Binomial b...
2010 Jan 19
1
splitting a factor in an analysis of deviance table (negative binomial model)
...quot;Alevel1",4),rep("Alevel2",4),rep("Alevel3",4),rep("Alevel4",4)),4),
"B"=c(rep("Blevel1",16),rep("Blevel2",16),rep("Blevel3",16),rep("Blevel4",16)),
"value"=rnegbin(64, 10, 10))
# fitting the model with interaction (a + b + a:b)
model <- glm.nb(value ~ A*B, data=my.data)
anova(model, test="F")
Df Deviance Resid. Df Resid. Dev F Pr(>F)
NULL 63 80.639
A 3 1.374 60 79.265 0.4581 0.7115
B 3 ...