Displaying 20 results from an estimated 20000 matches similar to: "how to to if a calculation is out range?"
2011 Dec 03
2
density function always evaluating to zero
Dear R users,
I'm trying to carry out monte carlo integration of a posterior density
function which is the product of a normal and a gamma distribution. The
problem I have is that the density function always returns 0. How can I
solve this problem?
Here is my code
#generate data
x1 <- runif(100, min = -10, max = 10)
y <- 2 * x1^2 + rnorm(100)
# # # # # # # # Model 0 # # # # # # #
2011 Feb 09
3
precision of gamma function
Dear R users,
I have to calculate gamma functions for negative numbers beyond -171.4.
e.x. gamma(-500.4)
I got following:
> gamma(-170.4)
[1] -5.824625e-308
> gamma(-171.4)
[1] 0
Warning message:
underflow occurred in 'gammafn'
I have tried to use a recursion getting values a little futher -180.
How could I solve this problem? Thank you beforehand.
Chuse.
2010 Jul 05
2
Function to compute the multinomial beta function?
Dear R-users,
Is there an R function to compute the multinomial beta function? That is, the normalizing constant that arises in a Dirichlet distribution. For example, with three parameters the beta function is Beta(n1,n2,n2) = Gamma(n1)*Gamma(n2)*Gamma(n3)/Gamma(n1+n2+n3)
Thanks in advance for any assisstance.
Regards,
Greg
[[alternative HTML version deleted]]
2005 Dec 05
3
The gamma function and infinity
I have to calculate some formula like:
gamma(x)/(gamma(x+y)
and I observed that for relatively big values of x, R
returns infinity and so cannot compute the formula. Is
it possible to force R to give the real value of
gamma(x) instead of Inf ?
thanks
2004 Jun 26
1
S4 group "Math", "getGroupMembers", "genericForPrimitive"
Hi,
I found the following on Windows 2000/NT
R Version 1.9.1 (2004-06-21) (also Version 1.9.0):
The S4 group "Math" doesn't work as documented; i.e., "log", "log10",
"gamma" and "lgamma" are included
in the documentation but don't work. See example code below.
Moreover, what about 'genericForPrimitive' which is used
in
2008 Apr 18
3
help me to debug this part of code?
I am trying to solve the integration equation, for different values of K from
4 to 25, the integration is with respect to u,
Here is the equation: gamma(k/2) / ( sqrt(k-1)*gamma((k-1)/2) ) *
integrate(f= (1+u^2/k-1)^(-k/2), lower=0, upper= sqrt(a^2*k/(k+1-a^2)) ) =
the similar expression as te left hand except k becomes k+1
my code is below, I don't know why R keep telling me the syntax
2000 Oct 04
2
gamma and lgamma functions (PR#684)
The following seems very strange:
> lgamma(-0.04)
[1] 3.243307
> gamma(-0.04)
[1] -25.61830
Jim
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To:
2007 Jan 26
1
Bayesian inference: Poisson distribution with normal (!) prior
Hello,
for a frequency modelling problem I want to combine expert knowledge with
incoming real-life data (which is not available up to now). The frequency
has to be modelled with a poisson distribution. The parameter lambda has to
be normal distributed (for certain reasons we did not NOT choose gamma
althoug it would make everything easier).
I've started with the subsequent two functions to
2009 Oct 24
2
Implementation of gamma function for large number
Hi - I ran into a problem when the argument to gamma function is
large. Says, if I do the following:
> gamma(17000)
[1] Inf
Warning message:
value out of range in 'gammafn'
Is there anyway to get around this or other implementation? Thank you.
-rc
2007 Mar 09
1
MCMC logit
Hi,
I have a dataset with the binary outcome Y(0,1) and 4 covariates (X1,X@,X#,X$). I am trying to use MCMClogit to model logistic regression using MCMC. I am getting an error where it doesnt identify the covariates ,although its reading in correctly. The dataset is a sample of actual dataset. Below is my code:
> #######################
>
>
> #retreive data
> # considering four
2004 Nov 08
4
About 'choose' function
Hello R-users,
When I didn't know about the internal 'choose'
function, I made such function, 'my.choose' below. But
when I used them instead of choose(6000,20), they
didn't give me any answer.
What is the difference between 'choose', 'my.choose1',
and 'my.choose2' below? That is, what is behind
'choose' function and what's the problem
2009 Jul 15
1
GLM Gamma Family logLik formula?
Hello all,
I was wondering if someone can enlighten me as to the difference
between the logLik in R vis-a-vis Stata for a GLM model with the gamma
family.
Stata calculates the loglikelihood of the model as (in R notation)
some equivalent function of
-1/scale * sum(Y/mu+log(mu)+(scale-1)*log(Y)+log(scale)+scale*lgamma(1/scale))
where scale (or dispersion) = 1, Y = the response variable, and mu
2009 Dec 15
3
RFC: lchoose() vs lfactorial() etc
lgamma(x) and lfactorial(x) are defined to return
ln|Gamma(x)| {= log(abs(gamma(x)))} or ln|Gamma(x+1)| respectively.
Unfortunately, we haven't chosen the analogous definition for
lchoose().
So, currently
> lchoose(1/2, 1:10)
[1] -0.6931472 -2.0794415 NaN -3.2425924 NaN -3.8869494
[7] NaN -4.3357508 NaN -4.6805913
Warning message:
In
2008 Apr 02
3
Fwd: Re: Nonlinear equation
> > >From: robert-mcfadden w o2.pl
> > >Date: 2008/04/02 Wed AM 09:58:28 CDT
> > >To: r-help w r-project.org
> > >Subject: [R] Nonlinear equation
> >
> > hi: you need to give an example and details or
> > you won't get much response, if any.
Equation e.g. (A, B are known constants):
3log(gamma(x))-log(gamma(x)*gamma(2x))+(x-1)*A+B=0
2011 Sep 19
2
Poisson-Gamma computation (parameters and likelihood)
Good afternoon/morning readers. This is the first time I am trying to run
some Bayesian computation in R, and am experiencing a few problems.
I am working on a Poisson model for cancer rates which has a conjugate Gamma
prior.
1) The first question is precisely how I work out the parameters.
#Suppose I assign values to theta with *seq()*
*theta<-seq(0,1,len=500)*
#Then I try out the
2007 Oct 14
1
Extending deriv3()
Hello,
I was wondering if the functions deriv3(), deriv() etc. could be extended
to handle psigamma() and its special cases (digamma(), trigamma()
etc.). From the error message it seems that 'psigamma' needs to be
added to the derivatives table.
This might be easy since psigamma() has a deriv argument.
Additionally, this error message is also obtained when requesting for
the Hessian of
2007 Sep 10
1
MLE Function
I am just trying to teach myself how to use the mle function in R because it is much better than what is provided in MATLAB. I am following tutorial material from the internet, however, it gives the following errors, does anybody know what is happening to cause such errors, or does anybody know any better tutorial material on this particular subject.
>
2009 Nov 20
1
Bessel function with large index value
I am looking for a method of dealing with the modified Bessel function
K_\nu(x) for large \nu.
The besselK function implementation of this allows for dealing with
large values of x by allowing for exponential scaling, but there is no
facility for dealing with large \nu.
What would work for me would be an lbesselK function in the manner of
lgamma which returned the log of K_\nu(x) for large
2007 Aug 30
2
Incomplete Gamma function
Hello
I am trying to evaluate an Incomplete gamma function
in R. Library Zipfr gives the Igamma function. From
Mathematica, I have:
"Gamma[a, z] is the incomplete gamma function."
In[16]: Gamma[9,11.1]
Out[16]: 9000.5
Trying the same in R, I get
> Igamma(9,11.1)
[1] 31319.5
OR
> Igamma(11.1,9)
[1] 1300998
I know I have to understand the theory and the math
behind it rather
2009 Jan 02
1
R: numerical integration problems
hello all
happy new year and hope you r having a good holiday.
i would like to calculate the expectation of a particular random variable and would like to approximate it using a number of the functions contained in R. decided to do some experimentation on a trivial example.
example
========
suppose x(i)~N(0,s2) where s2 = the variance
the prior for s2 = p(s2)~IG(a,b)
so the posterior is