Skip to content

Commit

Permalink
bug fix in startarg gamma
Browse files Browse the repository at this point in the history
  • Loading branch information
dutangc committed Jul 29, 2024
1 parent 61bb19c commit 60ab142
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: fitdistrplus
Title: Help to Fit of a Parametric Distribution to Non-Censored or Censored Data
Version: 1.2-1
Version: 1.2-2
Authors@R: c(person("Marie-Laure", "Delignette-Muller", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0001-5453-3994")),
person("Christophe", "Dutang", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0001-6732-1501")),
person("Regis", "Pouillot", role = "ctb"),
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# fitdistrplus 1.2-2

BUG FIX

- the default starting value for the gamma distribution was wrongly computed for the rate parameter.

# fitdistrplus 1.2-1

NEW FEATURES
Expand Down
2 changes: 1 addition & 1 deletion R/util-startarg.R
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ startarg_transgamma_family <- function(x, distr)
if(v > 0)
{
alphahat <- m^2/v
thetahat <- m/v
thetahat <- v/m
}else #exponential case
{
alphahat <- 1
Expand Down
6 changes: 6 additions & 0 deletions tests/t-startingvalues-trgamma-family.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ fitdist(x, "weibull")
fitdist(x, "exp")


x <- rgamma(n, 2, 2)

fitdistrplus:::startarg_transgamma_family(x, "gamma")



#weird examples
x <- rep(1, n)

Expand Down
9 changes: 5 additions & 4 deletions vignettes/starting-values.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ n/\tau + \alpha\sum_i \log(x_i/\theta)
+\sum_i \tau \frac{x_i}{\theta^2}(x_i/\theta)^{\tau-1}
\end{pmatrix}.
$$
We compute moment-estimator as in gamma
We compute the moment-estimator as in gamma \eqref{eq:gamma:relation}
$$
\hat\alpha = m_2^2/\mu_2,
\hat\theta= \mu_2/m_1.
Expand All @@ -766,11 +766,12 @@ $$

Transformed gamma with $\tau=1$

We compute moment-estimator as in gamma
$$
We compute the moment-estimator given by
\begin{equation}
\hat\alpha = m_2^2/\mu_2,
\hat\theta= \mu_2/m_1.
$$
\label{eq:gamma:relation}
\end{equation}


### Weibull distribution
Expand Down

0 comments on commit 60ab142

Please sign in to comment.