• Nenhum resultado encontrado

AdequacyModel

N/A
N/A
Protected

Academic year: 2021

Share "AdequacyModel"

Copied!
14
0
0

Texto

(1)

Package ‘AdequacyModel’

February 19, 2015

Type Package

Title Adequacy of probabilistic models and generation of pseudo-random numbers.

Version 1.0.8 Date 2013-09-12

Maintainer Pedro Rafael Diniz Marinho <pedro.rafael.marinho@gmail.com> Description This package provides some useful functions for calculating quality

measures for

adjustment, including statistics Kolmogorov-Smirnov, Cramer-von Mises and Anderson-Darling. These statistics are often used to compare models not equipped. Also provided are other measures of fitness, such as AIC, CAIC, BIC and HQIC. The package also provides functions for generating pseudo-random number of random variables that follow the following probability distribu-tions: Kumaraswamy Birnbaum-Saunders, Kumaraswamy Pareto, Exponentiated Weibull and Kumaraswamy Weibull.

URL http://www.r-project.org

License GPL (>= 2)

Author Pedro Rafael Diniz Marinho [aut, cre], Marcelo Bourguignon [aut, ctb], Cicero Rafael Bar-ros Dias [aut, ctb]

NeedsCompilation no Repository CRAN Date/Publication 2013-12-20 17:01:24

R topics documented:

AdequacyModel-package . . . 2 carbone . . . 2 descriptive . . . 3 goodness.fit . . . 4 kwbs . . . 7 kwp . . . 9 rew . . . 10 rkwweibull . . . 11 TTT . . . 12 1

(2)

2 carbone

Index 14

AdequacyModel-package Adequacy of probabilistic models and generation of pseudo-random numbers.

Description

This package provides some useful functions for calculating quality measures for adjustment, in-cluding statistics Kolmogorov-Smirnov, Cramer-von Mises and Anderson-Darling. These statistics are often used to compare models not equipped. Also provided are other measures of fitness, such as AIC, CAIC, BIC and HQIC. The package also provides functions for generating pseudo-random number of random variables that follow the following probability distributions: Kumaraswamy Birnbaum-Saunders, Kumaraswamy Pareto, Exponentiated Weibull and Kumaraswamy Weibull. Details Package: AdequacyModel Type: Package Version: 1.0 Date: 2012-11-15 License: GPL-2 Depends: R (>= 2.10.0) References

Chen, G., Balakrishnan, N. (1995). A general purpose approximate goodness-of-fit test. Journal of Quality Technology 27, 154-161.

carbone Breaking stress of carbon fibres

Description

The first real data set corresponds to an uncensored data set from Nichols and Padgett (2006) on breaking stress of carbon fibres (in Gba).

Usage

(3)

descriptive 3 Format

The format is: num [1:100] 3.7 2.74 2.73 2.5 3.6 3.11 3.27 2.87 1.47 3.11 ...

References

Nichols, M.D, Padgett, W.J. (2006). A Bootstrap control chart for Weibull percentiles. Quality and Reliability Engineering International 22, 141-151.

Examples

data(carbone) hist(carbone)

descriptive descriptive - Calculation of descriptive statistics

Description

The function descriptive calculates the main descriptive statistics of a vector of data.

Usage

descriptive(x)

Arguments

x Data vector.

Author(s)

Pedro Rafael Diniz Marinho <pedro.rafael.marinho@gmail.com> Marcelo Bourguignon <m.p.bourguignon@gmail.com>

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

Examples

data(carbone) descriptive(carbone)

(4)

4 goodness.fit

goodness.fit Adequacy of models

Description

This function provides some useful statistics to assess the quality of fit of probabilistic models, including the statistics Cramer-von Mises and Anderson-Darling. These statistics are often used to compare models not fitted. You can also calculate other goodness of fit such as AIC, CAIC, BIC, HQIC and Kolmogorov-Smirnov test.

Usage

goodness.fit(pdf, cdf, starts, data, method="L-BFGS-B", domain=c(0,Inf), mle=NULL)

Arguments

pdf Probability density function; cdf Cumulative distribution function;

starts Initial parameters to maximize the likelihood function; data Data vector;

method Method used for minimization of the function -log(likelihood). The meth-ods supported are: L-BFGS-B (default), BFGS, Nelder-Mead, SANN, CG. Can also be transmitted only the first letter of the methodology, ie, L, B, N, S or C respec-tively;

domain Domain of probability density function. By default the domain of probability density function is the open interval 0 to infinity.This option must be an vector with two values;

mle Vector with the estimation maximum likelihood. This option should be used if you already have knowledge of the maximum likelihood estimates. The default is NULL, ie, the function will try to obtain the estimates of maximum likelihoods. Details

The function goodness.fit returns statistics KS (Kolmogorov-Smirnov), A (Anderson-Darling), W (Cramer-von Misses). Are also calculated other measures of goodness of fit. These functions are: AIC (Akaike Information Criterion), CAIC (Consistent Akaikes Information Criterion), BIC (Bayesian Information Criterion) and HQIC (Hannan-Quinn information criterion).

The Kolmogorov-Smirnov test may return NA with a certain frequency. The return NA informs that the statistical KS is not reliable for the data set used. More details about this issue can be obtained fromks.test.

By default, the function calculates the maximum likelihood estimates. The errors of the estimates are also calculated. In cases that the function can not obtain the maximum likelihood estimates, the change of the values initial, in some cases, resolve the problem. You can also enter with the maximum likelihood estimation if there is already prior knowledge.

(5)

goodness.fit 5 Value

W Statistic Cramer-von Misses; A Statistic Anderson Darling; KS Kolmogorov Smirnov test; mle Maximum likelihood estimates; AIC Akaike Information Criterion;

CAIC Consistent Akaikes Information Criterion; BIC Bayesian Information Criterion;

HQIC Hannan-Quinn information criterion;

Erro Standard errors of the maximum likelihood estimates; Value Minimum value of the function -log(likelihood);

Convergence 0 indicates successful completion and 1 indicates that the iteration limit maxit had been reached. More details atoptim.

Note

It is not necessary to define the likelihood function or log-likelihood. You only need to define the probability density function and distribution function.

Author(s)

Pedro Rafael Diniz Marinho <pedro.rafael.marinho@gmail.com> References

Chen, G., Balakrishnan, N. (1995). A general purpose approximate goodness-of-fit test. Journal of Quality Technology, 27, 154-161.

Nocedal, J. and Wright, S. J. (1999) Numerical Optimization. Springer.

Sakamoto, Y., Ishiguro, M., and Kitagawa G. (1986). Akaike Information Criterion Statistics. D. Reidel Publishing Company.

Hannan, E. J. and Quinn, B. G. (1979). The Determination of the Order of an Autoregression. Journal of the Royal Statistical Society, Series B, 41, 190-195.

See Also

For details about the optimization methodologies may view the functionsoptim,ks.test,nlminb. Examples

# Example 1: data(carbone)

# Exponentiated Weibull - Probability density function. pdf_expweibull <- function(par,x){

(6)

6 goodness.fit

beta = par[1] c = par[2] a = par[3]

a * beta * c * exp(-(beta*x)^c) * (beta*x)^(c-1) * (1 - exp(-(beta*x)^c))^(a-1) }

# Exponentiated Weibull - Cumulative distribution function. cdf_expweibull <- function(par,x){ beta = par[1] c = par[2] a = par[3] (1 - exp(-(beta*x)^c))^a } goodness.fit(pdf=pdf_expweibull, cdf=cdf_expweibull, starts = c(1,1,1), data = carbone,

method="L-BFGS-B", domain=c(0,Inf),mle=NULL) # Example 2: data = c(0.08, 2.09, 3.48, 4.87, 6.94, 8.66, 13.11, 23.63, 0.20, 2.23, 3.52, 4.98, 6.97, 9.02, 13.29, 0.40, 2.26, 3.57, 5.06, 7.09, 9.22, 13.80, 25.74, 0.50, 2.46, 3.64, 5.09, 7.26, 9.47, 14.24, 25.82, 0.51, 2.54, 3.70, 5.17, 7.28, 9.74, 14.76, 26.31, 0.81, 2.62, 3.82, 5.32, 7.32, 10.06, 14.77, 32.15, 2.64, 3.88, 5.32, 7.39, 10.34, 14.83, 34.26, 0.90, 2.69, 4.18, 5.34, 7.59, 10.66, 15.96, 36.66, 1.05, 2.69, 4.23, 5.41, 7.62, 10.75, 16.62, 43.01, 1.19, 2.75, 4.26, 5.41, 7.63, 17.12, 46.12, 1.26, 2.83, 4.33, 5.49, 7.66, 11.25, 17.14, 79.05, 1.35, 2.87, 5.62, 7.87, 11.64, 17.36, 1.40, 3.02, 4.34, 5.71, 7.93, 11.79, 18.10, 1.46, 4.40, 5.85, 8.26, 11.98, 19.13, 1.76, 3.25, 4.50, 6.25, 8.37, 12.02, 2.02, 3.31, 4.51, 6.54, 8.53, 12.03, 20.28, 2.02, 3.36, 6.76, 12.07, 21.73, 2.07, 3.36, 6.93, 8.65, 12.63, 22.69) # Kumaraswamy Weibull Poisson - Probability density function. pdf_kwweibullpoisson <- function(par,x){ a = par[1] b = par[2] c = par[3] lambda = par[4] beta = par[5] (a*b*c*lambda*(beta^c)*(x^(c-1))*((1-exp(-(x*beta)^c))^(a-1)) * ((1-(1-exp(-(beta*x)^c))^a)^(b-1)) * exp(-lambda*(1-(1-(1-exp(-(beta*x)^c))^a)^b) - (beta*x)^c))/(1-exp(-lambda)) }

# Kumaraswamy Weibull Poisson - Cumulative distribution function. cdf_kwweibullpoisson <- function(par,x){

(7)

kwbs 7 b = par[2] c = par[3] lambda = par[4] beta = par[5] (1 - exp(lambda*(-(1-(1-(1-exp(-(x*beta)^c))^a)^b))))/(1-exp(-lambda)) } goodness.fit(pdf=pdf_kwweibullpoisson, cdf=cdf_kwweibullpoisson, starts = c(0.120,1.010,1.000,1.000,0.100), data = data, method="L-BFGS-B", domain=c(0,Inf),mle=NULL)

data = rweibull(250,2,3)

goodness.fit(pdf=pdf_kwweibullpoisson, cdf=cdf_kwweibullpoisson, starts = c(0.120,1.010,1.000,1.000,0.100), data = data, method="L-BFGS-B", domain=c(0,Inf),mle=NULL)

# Example 3:

# Kumaraswamy Beta - Probability density function. pdf_kwbeta <- function(par,x){ beta = par[1] a = par[2] alpha = par[3] b = par[4] (a*b*x^(alpha-1)*(1-x)^(beta-1)*(pbeta(x,alpha,beta))^(a-1)* (1-pbeta(x,alpha,beta)^a)^(b-1))/beta(alpha,beta) }

# Kumaraswamy Beta - Cumulative distribution function. cdf_kwbeta <- function(par,x){ beta = par[1] a = par[2] alpha = par[3] b = par[4] 1 - (1 - pbeta(x,alpha,beta)^a)^b } data = rbeta(1000,2,2.2)

goodness.fit(pdf = pdf_kwbeta, cdf=cdf_kwbeta, starts=c(0.5,1.02,2,1), data=data, method="L-BFGS-B", domain=c(0,1), mle=NULL)

kwbs Pseudo-Random Numbers - Kumaraswamy Birnbaum-Saunders Dis-tribution

Description

(8)

8 kwbs Usage

rkwbs(n, alpha, beta, a, b) Arguments

n Amount of generated numbers;

alpha Shape parameter of the Kumaraswamy Birnbaum-Saunders distribution; beta Scale parameter Kumaraswamy Birnbaum-Saunders distribution; a Shape parameter Kumaraswamy Birnbaum-Saunders distribution; b Shape parameter Kumaraswamy Birnbaum-Saunders distribution. Details

The additional parameters introduced by the Kumaraswamy generalization are sought as a manner to furnish a more flexible distribution. The Kw-BS distribution is expected to have immediate application in reliability and survival studies. The BS distribution arises as the basic exemplar for a = b = 1. The exponentiated Birnbaum-Saunders (EBS) distribution corresponds to b = 1. The Kw-BS is a particular case of the Mc-BS distribution when a = c; see Cordeiro et al. (2011).

F (x; α, β, a, b) = 1 − {1 − Φ(ν)a}b

where β > 0 is a scale parameter and the other positive parameters α, a, and b are shape parameters in that ν = α−1ρ(x/β), ρ(z) = z1/2− z−1/2and Φ(· ) denotes the standard normal distribution

function. Author(s)

Pedro Rafael Diniz Marinho <pedro.rafael.marinho@gmail.com> Marcelo Bourguignon <m.p.bourguignon@gmail.com>

References

Saulo, H.; Leao, J. and Bourguignon, M. The Kumaraswamy Birnbaum-Saunders Distribution. Journal of Statistical Theory and Practice 6, 745-759.

Cordeiro, G. M., and M. Castro. 2011. A new family of generalized distributions. J. Stat. Comput. Simulation, 81(7), 883-898.

Cordeiro, G.M. Lemonte, A.J. and Ortega, E.M.M. (2013). An extended fatigue life distribution. Statistics 47, 626-653. Examples a = 2.0 b = 2.5 alpha = 1.0 beta = 1.0 rkwbs(5, alpha, beta, a, b)

(9)

kwp 9

kwp Pseudo-Random Numbers - Kumaraswamy Pareto

Description

Generates pseudorandom numbers from Kumaraswamy Pareto Distribution. Usage

rkwp(n, k, beta, a, b) Arguments

n Amount of generated numbers;

k Shape parameter of the Kumaraswamy Pareto distribution; beta Scale parameter Kumaraswamy Pareto distribution; a Shape parameter Kumaraswamy Pareto distribution; b Shape parameter Kumaraswamy Pareto distribution. Details

The Kw-P (Kumaraswamy Pareto) distribution is not in fact very tractable. However, its heavy tail can adjust skewed data that cannot be properly fitted by existing distributions. Furthermore, the cumulative and hazard rate functions are simple. The Pareto distribution function Kumaraswamy function is given by F (x; β, k, a, b) = 1 − ( 1 − " 1 − β x k#a)b ,

where β > 0 (x >= β) is a scale parameter and the other positive parameters k, a and b are shape parameters.

Author(s)

Pedro Rafael Diniz Marinho <pedro.rafael.marinho@gmail.com> Marcelo Bourguignon <m.p.bourguignon@gmail.com>

References

Bourguinon, M.; Silva, R.B.; Zea, L.M. and Cordeiro, G.M. (2013). The Kumaraswamy Pareto distribution. Journal of Statistical Theory and Applications 12, 129-144.

See Also rweibull

(10)

10 rew Examples beta = 1.5 k = 1.5 a = 1.5 b = 3.5 x<-seq(beta, 10, 0.01) pdfKWP <- function(k,bet,a,b,x){ a*b*k*bet^(k)*(1-(beta/x)^k)^(a-1)*(1-(1-(beta/x)^k)^(a))^(b-1)/x^(k+1) }

hist(rkwp(100,k,beta,a,b), freq = FALSE,main="",xlab="x", ylab="Density",xlim=c(1.5,7),ylim=c(0,1.5),lwd=1) lines(x,pdfKWP(k,beta,a,b,x),lty=1,col="black",

lwd=1,type="l",xlim=c(1.5,7),ylim=c(0,1.5)) box()

rew Pseudo-Random Numbers - Exponentiated Weibull

Description

Generates pseudorandom numbers from Exponentiated Weibull Distribution.

Usage

rew(n, beta, c, a)

Arguments

n Amount of generated numbers;

beta Scale parameter of the Weibull distribution exponentiated; c Shape parameter Exponentiated Weibull distribution; a Shape parameter exponentiated Weibull distribution.

Details

The exponentiated Weibull family of probability distributions was introduced by Mudholkar and Srivastava (1993) as an extension of the Weibull family obtained by adding a second shape param-eter. The function is defined in positive real, ie x > 0.

F (x, β, c, a) = (1 − e−(β∗x)c)a, wherein β > 0, c > 0 and a > 0.

(11)

rkwweibull 11 Note

Making a = 1, we have the Weibull distribution. Making a = 1, we have the Weibull distribution. For k = 1 we have the exponentiated exponential distribution.

Author(s)

Pedro Rafael Diniz Marinho <pedro.rafael.marinho@gmail.com> References

Mudholkar, G.S.; Hutson, A.D. (1996). "The exponentiated Weibull family: some properties and a flood data application". Commun Stat Theory Meth 25: 3059-3083.

Mudholkar, G.S.; Srivastava, D.K. (1993). "Exponentiated Weibull family for analyzing bathtub failure-ratedata". IEEE Transactions on Reliability 42 (2): 299-302.

Mudholkar, G.S.; Srivastava, D.K.; Freimer, M. (1995). "The exponentiated Weibull family; a reanalysis of the bus motor failure data".

See Also rweibull

Examples

rew(20,7,2,1.7)

rkwweibull Pseudo-Random Numbers - Kumaraswamy Weibull

Description

Generates pseudorandom numbers from Kumaraswamy Weibull Distribution. Usage

rkwweibull(n, a, b, c, beta)

Arguments

n Amount of generated numbers;

a Shape parameter of the Kumaraswamy Weibull Distribution; b Shape parameter of the Kumaraswamy Weibull Distribution; c Shape parameter of the Kumaraswamy Weibull Distribution; beta Scale parameter of the Kumaraswamy Weibull Distribution.

(12)

12 TTT Details

The Kumaraswamy Weibull Distribution function is given by:

F (x, a, b, c) = 1 − {1 − [1 − e−(β∗x)c]a}b

The distribution was proposed by Cordeiro, Ortega and Nadarajah in 2010 in the Journal of the Franklin Institute. The distribution is defined on the positive real (x > 0). All parameters are also defined in the positive reals.

Author(s)

Pedro Rafael Diniz Marinho <pedro.rafael.marinho@gmail.com> References

Cordeiro, G.M.; Ortega, E.M.M., Nadarajah, S. (2010). "The Kumaraswamy Weibull distribution with application to failure data". Journal of the Franklin Institute, 347, 1399-1429.

Examples

rkwweibull(20,2,2.3,1.5,2)

TTT TTT function

Description

There are several behaviors that the failure rate function of a random variable T can take. In this context, the graph of total test time (TTT curve) proposed by Aarset (1987) may be used for obtain-ing empirical behavior of the function failure rate.

Usage

TTT(x, lwd = 2, lty = 2, col = "black", grid = TRUE, ...) Arguments

x Data vector;

lwd Thickness of the TTT curve. The argument lwd must be a nonnegative real number;

lty The argument lty modifies the style of the diagonal line chart TTT. Possible values are: 0 [blank], 1 [solid (default)], 2 [dashed], three [dotted], 4 [dotdash], 5 [longdash], 6 [twodash];

col Color used in the TTT curve;

grid If grid = FALSE graphic appears without the grid;

... Other arguments passed by the user and available for the function plot. More details inpar.

(13)

TTT 13 Note

The graphic TTT may have various forms. Aarset (1987) showed that if the curve approaches a straight diagonal function constant failure rate is adequate. When the curve is convex or concave the failure rate function is monotonically increasing or decescente respectively is adequate. If the failure rate function is convex and concave, the failure rate function in format U is adequate, otherwise the failure rate function unimodal is more appropriate.

The TTT curve is constructed by values r/n and G(r/n), wherein G(r/n) = [ Pn i=1Ti:n+ (n − r)Tr:n] Pn i=1Ti:n , r = 1, . . . , n, T1:n= 1, . . . , n. Author(s)

Pedro Rafael Diniz Marinho (pedro.rafael.marinho@gmail.com); Marcelo Bourguignon (m.p.bourguignon@gmail.com).

References

Aarset, M. V. (1987). How to identify bathtub hazard rate. IEEE Transactions Reliability, 36, 106-108.

Examples

data(carbone)

(14)

Index

∗Topic

Adequacy model

goodness.fit,4 ∗Topic

datasets

carbone,2 AdequacyModel(AdequacyModel-package),2 AdequacyModel-package,2 carbone,2 descriptive,3 goodness.fit,4 ks.test,4,5 kwbs,7 kwp,9 nlminb,5 optim,5 par,12 rew,10 rkwbs(kwbs),7 rkwp(kwp),9 rkwweibull,11 rweibull,9,11 TTT,12 14

Referências

Documentos relacionados

This paper presents a method to construct a basis of the probability space of orthogonal poly- nomials for general multivariate distributions with correlations between the random

create and interpret graphs; understand fundamental concepts of probability – events, conditional probability, independent events, random variables; identify the most

Na Tabela 5, são relacionadas as médias anuais dos percentuais de literatura estrangeira com a média anual do percentual de literatura nacional, com a proporção média anual

Sendo assim, os eventos empresariais têm de ser encarados como um processo de suporte á actividade da empresa, e como tal tem um workflow associado á sua criação,

30/10 of the Common Market Council, the &#34;Directrices para la Celebración de un Acuerdo de Inversiones en el MERCOSUR&#34; (Guidelines for Execution of an

As principais biografias sobre João Ribeiro foram lançadas na década de 1960, em comemoração ao seu centenário de nascimento, entre as quais merece destaque a feita por Mucio

Besides computing the cumulative distribution, probability density and quantile functions, the SMR package generates random samples of size N by Monte Carlo simulation..

A reparação judicial consubstanciada no Dano Moral é usada como uma forma de restauração nos processos no âmbito da justiça brasileira, visto que, com o advento do