Title: | Prediction for Future Data from any Continuous Distribution |
Version: | 1.0-12 |
Author: | H. M. Barakat [aut], O. M. Khaled [aut], Hadeer A. Ghonem [aut, cre] |
Maintainer: | Hadeer A. Ghonem <hadeer_ghonem15@yahoo.com> |
Description: | Functions to get prediction intervals and prediction points of future observations from any continuous distribution. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
LazyData: | TRUE |
Imports: | stats, fitdistrplus, Renext |
Suggests: | actuar, tolerance |
NeedsCompilation: | no |
Packaged: | 2020-02-19 12:30:29 UTC; USER |
Repository: | CRAN |
Date/Publication: | 2020-02-19 12:50:05 UTC |
Best fitting of a distribution to a data
Description
Fit of a distribution to a data by two methods: maximum likelihood (mle) and moment matching (mme). Kolmogorov-Smirnov test is used to construct the best fitting.
Usage
bestfit(data, dist , order=NULL, start=NULL, conf=0.95)
Arguments
data |
A numeric vector |
dist |
A character string |
order |
A numeric vector for the moment order(s). The length of this vector must be equal to the number of parameters to estimate. This argument may be omitted(default) for some distributions for which reasonable order are computed. |
start |
A named list giving the initial values of parameters of the named distribution. This argument may be omitted(default) for some distributions for which reasonable starting values are computed. |
conf |
Confidence level for the test. |
Details
This function is not intended to be called directly but is internally called in predI
and predP
.
It is assumed that the two methods: "mle" and "mme" are applied then Kolmogorov-Smirnov test is used to construct the best fitting.
Value
bestfit
returns a list with following components,
fit |
the parameter estimates. |
p.value |
the pvalue of the Kolmogorov-Smirnov Test. |
Author(s)
H. M. Barakat, O. M. Khaled and Hadeer A. Ghonem.
References
Delignette-Muller ML and Dutang C (2015), fitdistrplus: An R Package for Fitting Distributions. Journal of Statistical Software, 64(4), 1-34.
See Also
Examples
#best fitting of a logistic distribution
#
n=100
x1 <- rlogis(n, 0.5, 0.8)
bestfit(x1, "logis")
bestfit(x1, "logis")$p.value
Prediction interval for future observations
Description
Construct a prediction interval (PI) for future observations from any continuous distribution. Generic method is print
.
Usage
predI(data, dist, s, n, order=NULL, start=NULL, conf=0.95)
## S3 method for class 'predI'
print(x, ...)
Arguments
data |
A numeric vector |
dist |
A character string |
s |
A numeric vector for the order of the next observation. The length of this vector must be equal to 1. |
n |
A numeric vector for the size of all data. |
order |
A numeric vector for the moment order(s). The length of this vector must be equal to the number of parameters to estimate. This argument may be omitted(default) for some distributions for which reasonable order are computed. |
start |
A named list giving the initial values of parameters of the named distribution. This argument may be omitted(default) for some distributions for which reasonable starting values are computed. |
conf |
Confidence level for the test. |
x |
An object of class |
... |
Further argument to be passed to generic function |
Details
The dist argument is assumed to specify the distribution by the probability density function, the commulative distribution function and the quantile function (d, p, q).
By default, best fitting of the data based on maximum likelihood (mle) and moment matching (mme) methods is performed.
once the parameter(s) is(are) estimated, predI computes the prediction interval (PI) for the future observation.
This function will be called directly in predP
.
Value
predI
returns an object of class "predI"
, a list with the following components:
interval |
the prediction interval. |
lower |
the lower bound of the interval. |
upper |
the upper bound of the interval. |
distname |
the name of the distribution. |
parameters |
the parameter estimate. |
Generic function:
print
-
The print of a
"predI"
object shows few traces about the parameters and the prediction interval.
Author(s)
H. M. Barakat, O. M. Khaled and Hadeer A. Ghonem.
References
Delignette-Muller ML and Dutang C (2015), fitdistrplus: An R Package for Fitting Distributions. Journal of Statistical Software, 64(4), 1-34.
H. M. Barakat, Magdy E. El-Adll, Amany E. Aly (2014), Prediction intervals of future observations for a sample random size from any continuous distribution. Mathematics and Computers in Simulation, volume 97, 1-13.
See Also
Examples
# (1) prediction interval for the next observations based on normal distribution
#
set.seed(123)
x1 <- rnorm(15, 2, 4)
predI(x1, "norm", 16, 25)
# (2) prediction interval for the next observations based on weibull distribution
#
library(actuar)
set.seed(123)
x2 <- rweibull(16 , 2 , 3)
predI(x2, "weibull", 20, 20 )
Prediction point for future observations
Description
Construct a prediction point for future observations from any continuous distribution. Generic method is print
.
Usage
predP(data, dist, no, n, order=NULL, start=NULL, conf=0.95)
## S3 method for class 'predP'
print(x, ...)
Arguments
data |
A numeric vector |
dist |
A character string |
no |
A numeric vector for the number of the next observations. The length of this vector plus the length of the data must be less than or equal the length of all data. |
n |
A numeric vector for the size of all data. |
order |
A numeric vector for the moment order(s). The length of this vector must be equal to the number of parameters to estimate. This argument may be omitted(default) for some distributions for which reasonable order are computed. |
start |
A named list giving the initial values of parameters of the named distribution. This argument may be omitted(default) for some distributions for which reasonable starting values are computed. |
conf |
Confidence level for the test. |
x |
An object of class |
... |
Further argument to be passed to generic function |
Details
By default, best fitting of the data based on maximum likelihood (mle) and moment matching (mme) methods is performed. once the parameter(s) is(are) estimated, predP computes the prediction point(s) for the future observation(s).
Value
predP
returns an object of class "predP"
, a list with the following components:
data |
the new data with new observations. |
newobs |
the new observations. |
ns |
the rank of the new observations. |
no |
the number of the next observations. |
distname |
the name of the distribution. |
ld |
the length of the data. |
n |
the length of all the data. |
Generic function:
print
-
The print of a
"predP"
object shows the prediction point(s) for the future observation(s).
Author(s)
H. M. Barakat, O. M. Khaled and Hadeer A. Ghonem.
References
Delignette-Muller ML and Dutang C (2015), fitdistrplus: An R Package for Fitting Distributions. Journal of Statistical Software, 64(4), 1-34.
H. M. Barakat, Magdy E. El-Adll, Amany E. Aly (2014), Prediction intervals of future observations for a sample random size from any continuous distribution. Mathematics and Computers in Simulation, volume 97, 1-13.
H. M. Barakat, O. M. Khaled and Hadeer A. ghonem (2018), Predicting future lifetime based on random number for mixture exponential distribution. International conference of mathematics and its applications (ICMA18), April, 2018, Cairo, Egypt.
See Also
Examples
# prediction point for the next observations based on gamma distribution
#
set.seed(123)
x1 <- rgamma(10, 4, 2)
predP(x1, "gamma", 8, 20)
Prediction point and interval for mixture exponential distribution
Description
Construct a prediction point (Predicted point) and a prediction interval (PI) for mixture exponential distribution. Generic method is print
.
Usage
predmix(data, s, n, parameters, conf=0.95)
## S3 method for class 'predmix'
print(x, ...)
Arguments
data |
A numeric vector |
s |
A numeric vector for the order of the next observation. The length of this vector must be equal to 1. |
n |
A numeric vector for the size of all data. |
parameters |
A numeric vector for the parameters of the distribuion of the data. |
conf |
Confidence level for the test. |
x |
An object of class |
... |
Further argument to be passed to generic function |
Details
The parameters argument is assumed to specify the parameters for mixture of two exponential distributions by the mixing proportion, rate1 and rate2.
Value
predmix
returns an object of class "predmix"
, a list with the following components:
point |
the predicted point. |
interval |
the prediction interval. |
lower |
the lower bound of the interval. |
upper |
the upper bound of the interval. |
Generic function:
print
-
The print of a
"predmix"
object shows few traces about the predicted point and interval.
Author(s)
H. M. Barakat, O. M. Khaled and Hadeer A. Ghonem.
References
H. M. Barakat, O. M. Khaled, Hadeer A. Ghonem (2020), predicting future lifetime for mixture exponential distribution. Comm. Statist.- Sim. and Comp., DOI: 10.1080/03610918.2020.1715434.
See Also
Examples
# prediction for the next observation
#
set.seed(123)
library(Renext)
x<-sort(rmixexp2(30, 0.6, 2, 8))
predmix(x[1:25], 26, 30, c(0.6,2,8))
predmix(x[1:25], 29, 30, c(0.6,2,8))