Displaying 20 results from an estimated 10000 matches similar to: "generating a gamma random variable"
2000 Apr 14
1
rgamma with negative shape and scale parameters works?
Dear R people,
This is a possibly silly question, but the rgamma function takes the shape
and scale arguments and simulates gamma rvs corresponding to those values,
right? But the shape and scale parameters have to be positive, right?
However, rgamma quite happily returns to me values for negative values of
shape and scale, and in some cases returns negative values eg.
> rgamma(1, 1, -1)
[1]
2010 Jun 16
2
Fitting Gamma distribution
I'm looking for goodness of fit tests for gamma distributions with large data
sizes and for different data.
I have a matrix with around 4.000 data values in it and i have fitted a
gamma distribution with "fitdistr".
You can see the example:
> fitdistr(corpo,"gamma",lower=0.001)
Errore in optim(x = c(5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000,
5000, :
2007 May 20
2
section needed in FAQ - Using R (PR#9698)
Full_Name: Ray Kiddy
Version: R 2.5.0 GUI 1.19 (4308)
OS: Mac OS X 10.4.9
Submission from: (NULL) (71.139.33.60)
There is no section in the FAQ equivalent to "Using R". The "R Basics" is too
basic. I would say it addresses "meta-R" questions, such as installing.
I had a FAQ that I would think would be a basic "Using R" question, namely: "How
does
2012 Jan 27
2
The following code (using rgamma) hangs
Hi,
I'm seeing something that may be a bug in R's standalone math library,
which is packaged by Debian as r-mathlib. I reported it to the Debian BTS
as http://bugs.debian.org/657573
I'm using Debian squeeze, and the code was tested with r-mathlib 2.11.1-6
(default on stable) and 2.14.1-1 (from testing/unstable).
I summarize this report below. The following code with the R math
2002 Jan 24
2
random number generation issues with r and compiled C code
Dear People,
I have been writing a simulation routine that is currently entirely
written in c++. I've been using the R standalone math library to give me
random number generation for this. However, I have had to set the seed
myself, and I am using
set_seed(time(NULL), clock)
for every call to unif_rand().
However, this works really badly. The random numbers aren't uniform at
all. Does
2009 Jan 26
1
Goodness of fit for gamma distributions
I'm looking for goodness of fit tests for gamma distributions with large data
sizes. I have a matrix with around 10,000 data values in it and i have
fitted a gamma distribution over a histogram of the data.
The problem is testing how well that distribution fits. Chi-squared seems to
be used more for discrete distributions and kolmogorov-smirnov seems that
large sample sizes make it had to
2008 Jul 07
4
Plot Mixtures of Synthetically Generated Gamma Distributions
Hi,
I have the following vector
which is created from 3 distinct distribution (three components) of gamma:
x=c(rgamma(30,shape=.2,scale=14),rgamma(30,shape=12,scale=10),rgamma(30,shape=5,scale=6))
I want to plot the density curve of X, in a way that it shows
a distinct 3 curves that represent each component.
How can I do that?
I tried this but doesn't work:
lines(density(x))
Please
2005 Jul 27
7
gamma distribution
Hi R Users
This is a code I wrote and just want to confirm if the first 1000 values are raw
gamma (z) and the next 1000 values are transformed gamma (k) or not. As I get
2000 rows once I import into excel, the p - values beyond 1000 dont look that
good, they are very high.
--
sink("a1.txt");
for (i in 1:1000)
{
x<-rgamma(10, 2.5, scale = 10)
y<-rgamma(10, 2.5, scale = 10)
2005 Jun 25
1
comment in src/nmath/dgamma.c
Hi,
In src/nmath/dgamma.c the comment at the top says
* DESCRIPTION
*
* Computes the density of the gamma distribution,
*
* 1/s (x/s)^{a-1} exp(-x/s)
* p(x;a,s) = -----------------------
* (a-1)!
*
* where `s' is the scale (= 1/lambda in other parametrizations)
* and `a' is the shape parameter ( = alpha in
2009 Dec 11
2
Regularized gamma function/ incomplete gamma function
Dear all,
I would be very grateful if you could help me with:
Given the regularized gamma function Reg=int_0^r (x^(k-1)e^(-x))dx/int_0^Inf (x^(k-1)e^(-x))dx ; 0<r<Inf (which is eventually the ratio of the
Incomplete gamma function by the gamma function), does anyone know of a package in R that would evaluate the derivative of the inverse of Reg with respect to k? I am aware that the
2010 Mar 19
1
Gamma parametrization
Dear R users,
?rgamma gives me :
rgamma(n, shape, rate = 1, scale = 1/rate)
rate: an alternative way to specify the scale.
The Gamma distribution with parameters ‘shape’ = a and
‘scale’ = s has density
f(x)= 1/(s^a Gamma(a)) x^(a-1) e^-(x/s)
Should I understand that scale=1/rate ? Is it written somewhere ?
Then
2001 Feb 24
5
testing for integer
Dear People,
Consider the following fragment of R code
choose <- function(n,r)
{
if( is.integer(n) && is.integer(r) && n > 0 && r >= 0 )
{
.C("choose",as.double(n),as.double(r),comb = double(1))$comb
}
else stop("n must be a positive integer and r a non-negative integer.")
}
This is a practice function (n choose r), which I
2009 Sep 17
2
QQ plotting of various distributions...
Hello!
I am trying with this question again:
I would like to test few distributional assumptions for some behavioral
response data. There are few theories about true distribution of those
data, like: normal, lognormal, gamma, ex-Gaussian
(exponential-Gaussian), Wald (inverse Gaussian) etc. The best way would
be via qq-plot, to show to students differences. First two are trivial:
qqnorm(dat$X)
2008 Apr 30
3
checking whether a file is empty
Hi,
Is there a way to check whether a file is empty in R. I did the customary
searches, but did not find anything. Please cc me on any reply.
Thanks, Faheem.
2005 May 23
1
transform normally distributed random terms to gamma distributed random terms
Hi,
I have normally distributed random terms u~N(0,1). I want to get gamma distributed random terms g~(scale,shape) with
E(g)=1=shape/scale and var(g)=theta=1/scale=1/shape.
How can I reach my goal? The following way doesn't work: use the distribution function of u to get U(0,1)- distributed random
terms, then take the quantile function of the gamma distribution with shape and scale.
The
2007 May 18
1
Inverse gamma
Hi, All:
assume I need to generate X from inverse gamma with parameter (k, beta).
should I generate from Y from gamma(-k, beta),
then take X=1/Y?
Thanks
pat
2003 Apr 29
4
thick plot lines
Dear People,
In a qqplot I am doing, I get lines/points that are very thick. I've tried
setting the lwd variable to 0.1, but it doesn't seem to have any effect.
Also, I have set the value of lty to dashed, but I still get dots. The
command looks like
qqplot(cdf.inv(seq(0,1,length=size),theta,pos,len),empmargdistvec(len,theta,pos,size),
xlim=c(-theta,theta), ylim=c(-theta,theta),
2008 Aug 06
3
subsetting with column name as string
Hi,
Consider the following
> x = c(1,2)
> y = c(3,4)
> d = data.frame(cbind(x,y))
> d$x
[1] 1 2
> d$"x"
[1] 1 2
>
> foo = function(val)
+ {
+ return(d$val)
+ }
>
> bar = function()
+ {
+ return(d$"x")
+ }
>
> foo("x")
NULL
> bar()
[1] 1 2
I'm a little surprised that R accepts both the form d$x and d$"x", but
2010 Jul 21
4
Chi-square distribution probability density function:
Hi to all I found
an formular of an **
***p-Value Calculator for the Chi-Square test*
*http://www.danielsoper.com/statcalc/calc11.aspx*
*with the formula*
*http://www.danielsoper.com/statkb/topic11.aspx*
*what's the gamma function of this formula in r?*
*df=5*
*ch2=25.50878*
*the following code does not give the result <0.001 for the values above *
*p=
2001 Feb 08
4
eps file not positioned properly in latex document
Dear People,
I am trying to include a barplot (see code below), in a latex document.
However, the plot appears in totally the wrong position. I know this is
not an R question as such, but the eps file is produced by R and I thought
that perhaps other people had had similar problems and could give me
pointers. Am I doing anything obviously wrong?
Sincerely, Faheem Mitha.
PS.