Package 'bsgof'

Title: Birnbaum-Saunders Goodness-of-Fit Test
Description: Performs goodness-of-fit test for the Birnbaum-Saunders distribution and provides the maximum likelihood estimate and the method-of-moments estimate. For more details, see Park and Wang (2013) <arXiv:2308.10150>. This work was supported by the National Research Foundation of Korea (NRF) grants funded by the Korea government (MSIT) (No. 2022R1A2C1091319, RS-2023-00242528).
Authors: Chanseok Park [aut, cre] , Min Wang [ctb]
Maintainer: Chanseok Park <[email protected]>
License: GPL-2 | GPL-3
Version: 0.24.1
Built: 2025-02-02 05:25:27 UTC
Source: https://github.com/appliedstat/r

Help Index


The Birnbaum-Saunders distribution

Description

Density, distribution function, quantile function and random generation for the Birnbaum-Saunders distribution with alpha (shape) and beta (scale)

Usage

dbs(x, alpha = 1, beta = 1, log = FALSE)
pbs(q, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE)
qbs(p, alpha = 1, beta = 1, lower.tail = TRUE, log.p = FALSE)
rbs(n, alpha = 1, beta = 1)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations.

alpha

shape parameter.

beta

scale parameter.

log, log.p

logical; if TRUE, probabilities p are given as log(p).

lower.tail

logical; if TRUE (default), probabilities are P[Xx]P[X \le x] otherwise, P[X>x]P[X > x].

Details

The Birnbaum-Saunders distribution was proposed by Birnbaum and Saunders (1969) and its probability density function and cumulative distribution function are given by

f(x)=12πexp[12α2(xβ+βx2)]x32(x+β)2αβf(x) = \frac{1}{\sqrt{2\pi}} \exp\left[-\frac{1}{2\alpha^{2}} \left(\frac{x}{\beta}+\frac{\beta}{x}-2\right) \right] \frac{x^{-\frac{3}{2}} (x+\beta)}{2\alpha\sqrt{\beta}}

and

F(x)=Φ[1α(xββx)],F(x) = \Phi \Big[ \frac{1}{\alpha} \Big( \sqrt{\frac{x}{\beta}}-\sqrt{\frac{\beta}{x}} \Big) \Big],

where x>0x>0, α>0\alpha>0, and β>0\beta>0.

Value

dbs gives the density, pbs gives the distribution function, qbs gives the quantile function, and rbs generates random deviates.

Author(s)

Chanseok Park

References

Birnbaum, Z. W. and Saunders, S. C. (1969). A new family of life distributions. J. Appl. Probab. 6(2): 637-652.

Examples

dbs(1.5,  alpha=0.5, beta=1.5)
exp( dbs(1.5, alpha=0.5, beta=1.5, log=TRUE) )

pbs(2.5,  alpha=0.5, beta=1.5)
1 - pbs(2.5, alpha=0.5,beta=1.5, lower.tail = FALSE, log.p = FALSE)
1 - exp( pbs(2.5, alpha=0.5,beta=1.5, lower.tail = FALSE, log.p = TRUE) )

qbs(0.1, alpha=0.5, beta=1.5)
qbs(0.9, alpha=0.5, beta=1.5, lower.tail = FALSE, log.p = FALSE)
qbs(log(0.1), alpha=0.5, beta=1.5, lower.tail = TRUE,  log.p = TRUE)
qbs(log(0.9), alpha=0.5, beta=1.5, lower.tail = FALSE, log.p = TRUE)

rbs(n=10, alpha=0.5, beta=1.5)

Maximum likelihood estimates of Birnbaum-Saunders distribution

Description

Calculates the maximum likelihood estimates of Birnbaum-Saunders distribution.

Usage

bs.mle(x)

Arguments

x

a numeric vector of observations.

Details

The Birnbaum-Saunders distribution has the probability density function

f(x)=12πexp[12α2(xβ+βx2)]x32(x+β)2αβf(x) = \frac{1}{\sqrt{2\pi}} \exp\left[-\frac{1}{2\alpha^{2}} \left(\frac{x}{\beta}+\frac{\beta}{x}-2\right) \right] \frac{x^{-\frac{3}{2}} (x+\beta)}{2\alpha\sqrt{\beta}}

where x>0x>0, α>0\alpha>0, and β>0\beta>0. The parameters are estimated using the maximum likelihood method.

Value

An object of class "bs.estimate", a list with parameter estimates.

Author(s)

Chanseok Park

References

Birnbaum, Z. W. and Saunders, S. C. (1969). Estimation for a Family of Life Distributions with Applications to Fatigue. J. Appl. Probab. 6(2): 328-347.

See Also

bs.mme for the parameter estimation using the methof of moments.

Examples

# Aluminum-Coupons data set from Birnbaum and Saunders (1969).
data = c(0.37, 0.706, 0.716, 0.746, 0.785, 0.797, 0.844, 0.855, 0.858,
0.886, 0.886, 0.93, 0.96, 0.988, 0.99, 1, 1.01, 1.016, 1.018, 
1.02, 1.055, 1.085, 1.102, 1.102, 1.108, 1.115, 1.12, 1.134, 
1.14, 1.199, 1.2, 1.2, 1.203, 1.222, 1.235, 1.238, 1.252, 1.258,
1.262, 1.269, 1.27, 1.29, 1.293, 1.3, 1.31, 1.313, 1.315, 1.33,
1.355, 1.39, 1.416, 1.419, 1.42, 1.42, 1.45, 1.452, 1.475, 1.478,
1.481, 1.485, 1.502, 1.505, 1.513, 1.522, 1.522, 1.53, 1.54,
1.56, 1.567, 1.578, 1.594, 1.602, 1.604, 1.608, 1.63, 1.642,
1.674, 1.73, 1.75, 1.75, 1.763, 1.768, 1.781, 1.782, 1.792, 1.82,
1.868, 1.881, 1.89, 1.893, 1.895, 1.91, 1.923, 1.94, 1.945, 2.023,
2.1, 2.13, 2.215, 2.268, 2.44)

bs.mle(data)

Methof-of-moments estimates of Birnbaum-Saunders distribution

Description

Calculates the methof-of-moments estimates of Birnbaum-Saunders distribution.

Usage

bs.mme(x)

Arguments

x

a numeric vector of observations.

Details

The Birnbaum-Saunders distribution has the probability density function

f(x)=12πexp[12α2(xβ+βx2)]x32(x+β)2αβf(x) = \frac{1}{\sqrt{2\pi}} \exp\left[-\frac{1}{2\alpha^{2}} \left(\frac{x}{\beta}+\frac{\beta}{x}-2\right) \right] \frac{x^{-\frac{3}{2}} (x+\beta)}{2\alpha\sqrt{\beta}}

where x>0x>0, α>0\alpha>0, and β>0\beta>0.

The parameters are estimated using the methof-of-moments estimates method.

Value

An object of class "bs.estimate", a list with parameter estimates.

Author(s)

Chanseok Park

References

Birnbaum, Z. W. and Saunders, S. C. (1969). Estimation for a Family of Life Distributions with Applications to Fatigue. J. Appl. Probab. 6(2): 328-347.

See Also

bs.mle for the parameter estimation using the maximum likelihood method.

Examples

# Aluminum-Coupons data set from Birnbaum and Saunders (1969).
data = c(0.37, 0.706, 0.716, 0.746, 0.785, 0.797, 0.844, 0.855, 0.858,
0.886, 0.886, 0.93, 0.96, 0.988, 0.99, 1, 1.01, 1.016, 1.018,
1.02, 1.055, 1.085, 1.102, 1.102, 1.108, 1.115, 1.12, 1.134,
1.14, 1.199, 1.2, 1.2, 1.203, 1.222, 1.235, 1.238, 1.252, 1.258,
1.262, 1.269, 1.27, 1.29, 1.293, 1.3, 1.31, 1.313, 1.315, 1.33,
1.355, 1.39, 1.416, 1.419, 1.42, 1.42, 1.45, 1.452, 1.475, 1.478,
1.481, 1.485, 1.502, 1.505, 1.513, 1.522, 1.522, 1.53, 1.54,
1.56, 1.567, 1.578, 1.594, 1.602, 1.604, 1.608, 1.63, 1.642,
1.674, 1.73, 1.75, 1.75, 1.763, 1.768, 1.781, 1.782, 1.792, 1.82,
1.868, 1.881, 1.89, 1.893, 1.895, 1.91, 1.923, 1.94, 1.945, 2.023,
2.1, 2.13, 2.215, 2.268, 2.44)

bs.mme(data)

Birnbaum-Saunders Probability Plot

Description

bs.plot produces a Birnbaum-Saunders probability plot.

Usage

bs.plot(x, plot.it=TRUE, a, col.line="black", lty.line=1,  
        xlim=NULL, ylim=NULL, main=NULL, sub=NULL, xlab=NULL, ylab="Probability", ...)

Arguments

x

a numeric vector of data values. Missing values are allowed.

plot.it

logical. Should the result be plotted?

a

the offset fraction to be used; typically in (0,1). See ppoints.

col.line

the color of the straight line.

lty.line

the line type of the straight line.

xlim

the x limits of the plot.

ylim

the y limits of the plot.

main

a main title for the plot, see also title.

sub

a sub title for the plot.

xlab

a label for the x axis, defaults to a description of x.

ylab

a label for the y axis, defaults to "Probability".

...

graphical parameters.

Details

The Birnbaum-Saunders probability plot is based on the linearization proposed by Chang and Tang (1994).

Value

A list with the following components:

x

The sorted data

w

sqrt(x)*qnorm(p)

Author(s)

Chanseok Park

References

Chang, D. S and Tang, L. C. (1994). Graphical analysis for Birnbaum-Saunders distribution. Microelectronics Reliability 34: 17-22.

Birnbaum, Z. W. and Saunders, S. C. (1969). Estimation for a Family of Life Distributions with Applications to Fatigue. J. Appl. Probab. 6(2): 328-347.

See Also

qqnorm, qqplot, and wp.plot for the Weibull probability plot in package weibullness.

Examples

# Data set from Birnbaum and Saunders (1969).
attach(BSdata)
data = psi21k
bs.plot(data)

# Adding cosmetic lines
bs.plot(data, main="BS probability plot", lty.line=2, pch=3, col.line="red")

ticklabels=c(0.01, seq(0.1,0.9,by=0.1), seq(0.91,0.99,by=0.01) )
qn = quantile(data, probs=ticklabels) 
ticksat= qnorm(ticklabels)* sqrt( qn )
hline =  qnorm( ticklabels  ) *  sqrt( qn )

abline( h=hline,    col=gray(0.5), lty=3, lwd=0.6 )
abline( v=  seq(0, 2500, by=100), col=gray(0.5), lty=3, lwd=0.5 )

abline( h= qnorm(0.5)*sqrt(median(data)), col=gray(0.1), lty=1, lwd=0.6 )
abline( v= median(data), col=gray(0.1), lty=1, lwd=0.6 )

Quantile values of Birnbaum-Saunders distribution

Description

Quantiles for the goodness of fit test for the Birnbaum-Saunders distribution from the probability plot. They are obtained from the sample correlation from the Birnbaum-Saunders probability plot. Monte Carlo iteration is 1E08.

Usage

bs.plot.quantiles

Format

This data frame contains 998 rows and 1001 columns.

Value

Quantile values between zero and one.

Author(s)

Chanseok Park

References

Park, C. and M. Wang (2023). A goodness-of-fit test for the Birnbaum-Saunders distribution based on the probability plot. ArXiv e-prints, 2308.10150.
doi:10.48550/arXiv.2308.10150


The Birnbaum-Saunders goodness-of-fit test from the probability plot

Description

Performs goodness-of-fit test for the Birnbaum-Saunders distribution

Usage

bs.test(x, a)
bs.test.pvalue(r, n)
bs.test.critical(alpha, n)

Arguments

x

a numeric vector of data values. Missing values are allowed, but the number of non-missing values must be between 3 and 1000.

a

the offset fraction to be used; typically in (0,1). See ppoints.

r

the sample correlation coefficient from the Birnbaum-Saunders probability plot; r is in (0,1).

n

the sample size.

alpha

the significance level.

Details

Using the sample correlation coefficeint from the Birnbaum-Saunders probability plot, it performs the goodness fit test for the Birnbaum-Saunders distribution.

Value

A list with class "htest" containing the following components:

statistic

the value of the test statistic (sample correlation from the Birnbaum-Saunders probability plot)

p.value

the p-value for the test.

sample.size

sample size (missing observations are deleted).

method

a character string indicating the goodness fit test for the Birnbaum-Saunders distribution.

data.name

a character string giving the name(s) of the data.

Author(s)

Chanseok Park

References

Park, C. and M. Wang (2023). A goodness-of-fit test for the Birnbaum-Saunders distribution based on the probability plot. ArXiv e-prints, 2308.10150.
doi:10.48550/arXiv.2308.10150

See Also

ks.test for performing a one- or two-sample Kolmogorov-Smirnov test.
shapiro.test for performing the Shapiro-Wilk test of normality.
wp.test{weibullness} for performing the Weibullness test.

Examples

# For the goodness of fit test
x = c(1.2, 2.0, 3.3)
bs.test(x)

# p.value with r (sample correlation from the probability plot) and n (sample size) are given
bs.test.pvalue(r=0.6, n=10)

# Critical value with alpha (significane level) and n (sample size).
bs.test.critical(alpha=0.01, n=10)

Data set

Description

psi21k, psi26k, and psi31k are from Birnbaum and Saunders (1969). The fatigue lifetimes of aluminum specimens exposed to a maximum stress of 21,000 psi, 26,000 psi, 31,000 psi, respectively.

bearings is from McCool (1974). The fatigue lifetimes (in hours) of ten bearings.

fatigue is from Brown and Miller (1978). The fatigue lifetimes of cylindrical specimens subjected to combined torsional and axial loads over constant-amplitude cycles until failure.

repair is from Hsieh (1990). This is a maintenance data set on active repair times (in hours) for an airborne communications transceiver.

Usage

BSdata

References

Birnbaum, Z. W. and Saunders, S. C. (1969). A new family of life distributions. J. Appl. Probab. 6(2): 637-652.

McCool, J. I. (1974). Inferential techniques for Weibull populations. Aerospace Research Laboratories Report ARL T R74-0180, Wright-Patterson Air Force Base, Dayton, OH.

Rieck, J. R. and Nedelman, J. (1991). A Log-Linear Model for the Birnbaum-Saunders Distribution. Technometrics. 33, 51-60.

Brown, M. W. and Miller, K. J. (1978). Biaxial Fatigue Data. Report CEMR1/78. University of Sheffield, Dept. of Mechanical Engineering.

Hsieh, H. K. (1990). Estimating the Critical Time of Inverse Gaussian Hazard Rate. IEEE Transactions on Reliability, 39(10): 342-345.

Examples

# Attach data sets
attach(BSdata)
psi21k
psi26k
psi31k
bearings
fatigue
repair

Print the estimated values

Description

Printing objects of class "bs.estimate".

Value

No return value, printing objects of class

See Also

bs.mle, bs.mme, print


Print the critical value for bs.test

Description

Printing objects of class "bs.test.critical.value".

Value

No return value, printing objects of class

See Also

bs.test.critical, print