Title: | Generalized Logistic Distribution |
---|---|
Description: | Provides basic distribution functions for a generalized logistic distribution proposed by Rathie and Swamee (2006) <https://www.rroij.com/open-access/on-new-generalized-logistic-distributions-and-applicationsbarreto-fhs-mota-jma-and-rathie-pn-.pdf>. It also has an interactive 'RStudio' plot for better guessing dynamically of initial values for ease of included optimization and simulating. |
Authors: | Eduardo Hellas [aut, cre], Eduardo Monteiro [aut, ctb] |
Maintainer: | Eduardo Hellas <[email protected]> |
License: | GPL-3 |
Version: | 1.0.2 |
Built: | 2025-01-26 03:40:25 UTC |
Source: | https://github.com/pinduzera/genlogis |
Density, distribution function, quantile function and random generation a generalized logistic distribution.
pgenlog(q, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, lower.tail = TRUE) dgenlog(x, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0) qgenlog(k, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, lower.tail = TRUE) rgenlog(n, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0)
pgenlog(q, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, lower.tail = TRUE) dgenlog(x, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0) qgenlog(k, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, lower.tail = TRUE) rgenlog(n, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0)
a , b , p
|
parameters |
mu |
mu parameter |
lower.tail |
logical; if TRUE (default), probabilities are |
x , q
|
vector of quantiles. |
k |
vector of probabilities. |
n |
number of observations. If length(n) > 1, the length is taken to be the number required |
The used distribution for this package is given by:
The default values for a, b, p and mu
produces a function with mean 0 and variance close to 1.
*Restrictions:
If p
equals to 0, b
or a
must be 0 otherwise there is identifiability problem.
The distribution is not defined for a
and b
equal to 0 simultaneously.
dgenlog
gives the density, pgenlog
gives the distribution function,
qgenlog
gives the quantile function, and rgenlog
generates random deviates.
The length of the result is determined by n
for rgenlog
, and is the maximum of the lengths
of the numerical arguments for the other functions.
Rathie, P. N. and Swamee, P. K (2006) On a new invertible generalized logistic distribution approximation to normal distribution, Technical Research Report in Statistics, 07/2006, Dept. of Statistics, Univ. of Brasilia, Brasilia, Brazil.
pgenlog(0.5) curve(dgenlog(x), xlim = c(-3,3)) rgenlog(100) qgenlog(0.95)
pgenlog(0.5) curve(dgenlog(x), xlim = c(-3,3)) rgenlog(100) qgenlog(0.95)
Density, distribution function, quantile function and random generation a generalized logistic distribution with skewness.
pgenlog_sk( q, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, skew = 0.5, lower.tail = TRUE ) dgenlog_sk(x, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, skew = 0.5) qgenlog_sk( k, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, skew = 0.5, lower.tail = TRUE ) rgenlog_sk(n, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, skew = 0.5)
pgenlog_sk( q, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, skew = 0.5, lower.tail = TRUE ) dgenlog_sk(x, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, skew = 0.5) qgenlog_sk( k, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, skew = 0.5, lower.tail = TRUE ) rgenlog_sk(n, a = sqrt(2/pi), b = 0.5, p = 2, mu = 0, skew = 0.5)
a , b , p
|
parameters |
mu |
mu parameter |
skew |
skewness parameter limited to the interval (-1, 1) |
lower.tail |
logical; if TRUE (default), probabilities are |
x , q
|
vector of quantiles. |
k |
vector of probabilities. |
n |
number of observations. If length(n) > 1, the length is taken to be the number required |
The used distribution for this package is given by:
The default values for a, b, p and mu
produces a function with mean 0 and variance close to 1.
*Restrictions:
If p
equals to 0, b
or a
must be 0 otherwise there is identifiability problem.
The distribution is not defined for a
and b
equal to 0 simultaneously.
dgenlog_sk
gives the density, pgenlog_sk
gives the distribution function,
qgenlog_sk
gives the quantile function, and rgenlog_sk
generates random deviates.
The length of the result is determined by n
for rgenlog_sk
, and is the maximum of the lengths
of the numerical arguments for the other functions.
Rathie, P. N. and Swamee, P. K (2006) On a new invertible generalized logistic distribution approximation to normal distribution, Technical Research Report in Statistics, 07/2006, Dept. of Statistics, Univ. of Brasilia, Brasilia, Brazil.
Azzalini, A. (1985) A class of distributions which includes the normal ones. Scandinavian Journal of Statistics.
pgenlog_sk(0.5) curve(dgenlog_sk(x), xlim = c(-3,3)) rgenlog_sk(100) qgenlog_sk(0.95)
pgenlog_sk(0.5) curve(dgenlog_sk(x), xlim = c(-3,3)) rgenlog_sk(100) qgenlog_sk(0.95)
Maximum likehood estimation of parameters for a generalized logistic distribution.
genlog_mle(parameters, data, hessian = F, alpha = 0.05)
genlog_mle(parameters, data, hessian = F, alpha = 0.05)
parameters |
Initial values for the parameters to be optimized over in the following order |
data |
This is the the data to be utilized for the estimation. |
hessian |
logical value that returns hessian, also returns the parameters estimation's confidence interval. |
alpha |
Type I error given to calculate confidence intervals, used when |
Maximum likehood estimation of parameters for the distribution proposed in this package.
This function is an application of constrOptim
as a particular case needed for this
distribution using the method "BFGS
".
For more information of the output check help(constrOptim)
.
The used distribution for this package is given by:
help(dgenlog)
for parameters restrictions.
Return a list of components as constrOptim
\(for more information, check this function\)
with some extras:
par
The best set of parameters found.
value
The value of the loglikelihood function corresponding to par
.
counts
A two-element integer vector giving the number of calls to the likelihood
function and BFGS
respectively. This excludes those calls needed to
compute the Hessian, and any calls to likelihood function to compute a
finite-difference approximation to the gradient.
convergence
An integer code. 0 indicates successful completion, 1 indicates that
the iteration limit maxit
had been reached. For more errors help(constrOptim)
.
message
A character string giving any additional information returned by the optimizer,
or NULL.
outer.iterations
gives the number of outer iterations (calls to optim
).
barrier.value
giving the value of the barrier function at the optimum.
For hessian = T
add:
hessian
A symmetric matrix giving an estimate of the (negative) Hessian at the solution found.
Note that this is the Hessian of the unconstrained problem even if the box
constraints are active.
bounds
Return the best parameters found and the upper and lower bounds for the estimation.
Rathie, P. N. and Swamee, P. K. (2006) On a new invertible generalized logistic distribution approximation to normal distribution, Technical Research Report in Statistics, 07/2006, Dept. of Statistics, Univ. of Brasilia, Brasilia, Brazil.
Byrd, R. H., Lu, P., Nocedal, J. and Zhu, C. (1995) A limited memory algorithm for bound constrained optimization. SIAM J. Scientific Computing, 16, 1190-1208.
## Using generic parameter starting values datas <- rgenlog(10000, 1.5,2,2, 0) genlog_mle(c(.5,1.6, 1.5, 0),datas) ## Select parameters starting values with genlog_slider datas <- rgenlog(10000, 1.5,2,2, 0) if (manipulate::isAvailable()) { genlog_slider(datas, return_var = 'parameters') ## choose parameters } else { parameters <- c(1.345, 2, 2, -0.00510) } genlog_mle(parameters,datas)
## Using generic parameter starting values datas <- rgenlog(10000, 1.5,2,2, 0) genlog_mle(c(.5,1.6, 1.5, 0),datas) ## Select parameters starting values with genlog_slider datas <- rgenlog(10000, 1.5,2,2, 0) if (manipulate::isAvailable()) { genlog_slider(datas, return_var = 'parameters') ## choose parameters } else { parameters <- c(1.345, 2, 2, -0.00510) } genlog_mle(parameters,datas)
Maximum likehood estimation of parameters for a generalized logistic distribution with skewness.
genlog_mle_sk(parameters, data, hessian = F, alpha = 0.05)
genlog_mle_sk(parameters, data, hessian = F, alpha = 0.05)
parameters |
Initial values for the parameters to be optimized over in the following order |
data |
This is the the data to be utilized for the estimation. |
hessian |
logical value that returns hessian, also returns the parameters estimation's confidence interval. |
alpha |
Type I error given to calculate confidence intervals, used when |
Maximum likehood estimation of parameters for the distribution proposed in this package.
This function is an application of constrOptim
as a particular case needed for this
distribution using the method "BFGS
".
For more information of the output check help(constrOptim)
.
The used distribution for this package is given by:
help(dgenlog_sk)
for parameters restrictions.
Return a list of components as constrOptim
\(for more information, check this function\)
with some extras:
par
The best set of parameters found.
value
The value of the loglikelihood function corresponding to par
.
counts
A two-element integer vector giving the number of calls to the likelihood
function and L-BFGS-B
respectively. This excludes those calls needed to
compute the Hessian, and any calls to likelihood function to compute a
finite-difference approximation to the gradient.
convergence
An integer code. 0 indicates successful completion, 1 indicates that
the iteration limit maxit
had been reached. For more errors help(constrOptim)
.
message
A character string giving any additional information returned by the optimizer,
or NULL.
outer.iterations
gives the number of outer iterations (calls to optim
).
barrier.value
giving the value of the barrier function at the optimum.
For hessian = T
add:
hessian
A symmetric matrix giving an estimate of the (negative) Hessian at the solution found.
Note that this is the Hessian of the unconstrained problem even if the box
constraints are active.
bounds
Return the best parameters found and the upper and lower bounds for the estimation.
Rathie, P. N. and Swamee, P. K. (2006) On a new invertible generalized logistic distribution approximation to normal distribution, Technical Research Report in Statistics, 07/2006, Dept. of Statistics, Univ. of Brasilia, Brasilia, Brazil.
Azzalini, A. (1985) A class of distributions which includes the normal ones. Scandinavian Journal of Statistics.
Byrd, R. H., Lu, P., Nocedal, J. and Zhu, C. (1995) A limited memory algorithm for bound constrained optimization. SIAM J. Scientific Computing, 16, 1190-1208.
## Using generic parameter starting values datas <- rgenlog_sk(10000, 0.3,0.9,1.5, 0, 0.9) genlog_mle_sk(c(0.3,0.9,1.5, 0, 0.9),datas) ## Select parameters starting values with genlog_slider datas <- rgenlog(10000, 1.5,2,2, 0) if (manipulate::isAvailable()) { genlog_slider(datas, return_var = 'parameters', skew = T) ## choose parameters } else { parameters <- c( 1, 1.5, 1.3, 0.5, -.4) } genlog_mle_sk(parameters, datas)
## Using generic parameter starting values datas <- rgenlog_sk(10000, 0.3,0.9,1.5, 0, 0.9) genlog_mle_sk(c(0.3,0.9,1.5, 0, 0.9),datas) ## Select parameters starting values with genlog_slider datas <- rgenlog(10000, 1.5,2,2, 0) if (manipulate::isAvailable()) { genlog_slider(datas, return_var = 'parameters', skew = T) ## choose parameters } else { parameters <- c( 1, 1.5, 1.3, 0.5, -.4) } genlog_mle_sk(parameters, datas)
Creating a simulation of the generalized logistic distribution maximum likelihood estimation of the parameters
with parallelized processing code using the foreach
package.
genlog_simu(real.par, init.par, sample.size = 100, k = 1000, seed = 555, threads = 1, progress.bar = T)
genlog_simu(real.par, init.par, sample.size = 100, k = 1000, seed = 555, threads = 1, progress.bar = T)
real.par |
the real parameters value of the distribution wich the random sample will be taken. It has to be a vector of length 4,
the parameters are the values of |
init.par |
Initial values for the parameters to be optimized over in the following order |
sample.size |
the sample size to be taken in each |
k |
the number of simulations. |
seed |
seed to be given to |
threads |
the numbers of CPU threads to be used for parallel computing. If the threads number is higher than the available the maximum allowed will be used. |
progress.bar |
show progress bar for each thread during simulations, default value |
The used distribution for this package is given by:
For more about the distribution use help(dgenlog)
.
It returns a data.frame with k
rows (each simulation) and 7 columns with the following information:
a, b, p
and mu
are estimations using maximum likelihood estimation, for more info help(genlogis_mle)
sample.size
The sample size used for each k
simulation.
convergence
The estimation's convergence status.
Rathie, P. N. and Swamee, P. K. (2006) On a new invertible generalized logistic distribution approximation to normal distribution, Technical Research Report in Statistics, 07/2006, Dept. of Statistics, Univ. of Brasilia, Brasilia, Brazil.
genlog_simu(real.par = c(0.3, 0.9, 1.5, 0.0), init.par = c(0.9, 0.3, 0.2, 0.0), sample.size = 100, k = 50, threads = 2, seed = 200)
genlog_simu(real.par = c(0.3, 0.9, 1.5, 0.0), init.par = c(0.9, 0.3, 0.2, 0.0), sample.size = 100, k = 50, threads = 2, seed = 200)
Creating a simulation of the generalized logistic distribution with skewness maximum likelihood estimation of the parameters
with parallelized processing code using the foreach
package.
genlog_simu_sk(real.par, init.par, sample.size = 100, k = 1000, seed = 555, threads = 1, progress.bar = T)
genlog_simu_sk(real.par, init.par, sample.size = 100, k = 1000, seed = 555, threads = 1, progress.bar = T)
real.par |
the real parameters value of the distribution wich the random sample will be taken. It has to be a vector of length 5,
the parameters are the values of |
init.par |
Initial values for the parameters to be optimized over in the following order |
sample.size |
the sample size to be taken in each |
k |
the number of simulations. |
seed |
seed to be given to |
threads |
the numbers of CPU threads to be used for parallel computing. If the threads number is higher than the available the maximum allowed will be used. |
progress.bar |
show progress bar for each thread during simulations, default value |
The used distribution for this package is given by:
It returns a data.frame with k
rows (each simulation) and 7 columns with the following information:
a, b, p
and mu
are estimations using maximum likelihood estimation, for more info help(genlogis_mle)
sample.size
The sample size used for each k
simulation.
convergence
The estimation's convergence status.
Rathie, P. N. and Swamee, P. K (2006) On a new invertible generalized logistic distribution approximation to normal distribution, Technical Research Report in Statistics, 07/2006, Dept. of Statistics, Univ. of Brasilia, Brasilia, Brazil.
Azzalini, A. (1985) A class of distributions which includes the normal ones. Scandinavian Journal of Statistics.
genlog_simu_sk(real.par = c(0.3, 0.9, 1.5, 0.0, .9), init.par = c(0.9, 0.3, 0.2, 0.0, .9), sample.size = 100, k = 50, threads = 2, seed = 200)
genlog_simu_sk(real.par = c(0.3, 0.9, 1.5, 0.0, .9), init.par = c(0.9, 0.3, 0.2, 0.0, .9), sample.size = 100, k = 50, threads = 2, seed = 200)
Make a generalized logistic distribution slider to compare histogram with theoretical distribution
genlog_slider(data, return_var = NULL, mu_range = 10, skew = F)
genlog_slider(data, return_var = NULL, mu_range = 10, skew = F)
data |
vector of data to compare. |
return_var |
a char string to name where parameters are assigned |
mu_range |
a number to setup the minimum and maximum range value of the mu parameter |
skew |
logical, if |
There is a small gear in the top left of the graphic where you can slide the parameters @param a,b,p,mu
.
The used distribution for this package is given by:
If the density function is not printed it is not defined for these parameters.
For skew = T
the model used is
The used distribution for is given by:
#' for more information about the model (help(dgenlog_sk)
)
If the density function is not printed it is not defined for these parameters.
help(dgenlog)
for parameters restrictions.
This function requires RStudio to run.
The function plots a interactive graphic in RStudio Viewer panel.
Also, the parameters a, b, p
and mu
can be returned to
return_var
if asked in the graphic.
Rathie, P. N. and Swamee, P. K (2006) On a new invertible generalized logistic distribution approximation to normal distribution, Technical Research Report in Statistics, 07/2006, Dept. of Statistics, Univ. of Brasilia, Brasilia, Brazil.
Azzalini, A. (1985) A class of distributions which includes the normal ones. Scandinavian Journal of Statistics.
## Not run: datas <- rgenlog(1000) if (manipulate::isAvailable()) { genlog_slider(datas, return_var = 'parameters') } ## End(Not run)
## Not run: datas <- rgenlog(1000) if (manipulate::isAvailable()) { genlog_slider(datas, return_var = 'parameters') } ## End(Not run)