Package 'bssn'

Title: Birnbaum-Saunders Model
Description: It provides the density, distribution function, quantile function, random number generator, reliability function, failure rate, likelihood function, moments and EM algorithm for Maximum Likelihood estimators, also empirical quantile and generated envelope for a given sample, all this for the three parameter Birnbaum-Saunders model based on Skew-Normal Distribution. Also, it provides the random number generator for the mixture of Birnbaum-Saunders model based on Skew-Normal distribution. Additionally, we incorporate the EM algorithm based on the assumption that the error term follows a finite mixture of Sinh-normal distributions.
Authors: Luis Benites Sanchez[cre, aut] <[email protected]>, Rocio Paola Maehara[cre, aut] <[email protected]> and Paulo Jos<c3><a9> Alejandro Aybar Flores[ctb] <[email protected]>
Maintainer: Rocio Paola Maehara <[email protected]>
License: GPL (>= 2)
Version: 1.0
Built: 2024-12-17 06:52:20 UTC
Source: CRAN

Help Index


Birnbaum-Saunders model

Description

It provides the density, distribution function, quantile function, random number generator, reliability function, failure rate, likelihood function, moments and EM algorithm for Maximum Likelihood estimators, also empirical quantile and generated envelope for a given sample, all this for the three parameter Birnbaum-Saunders model based on Skew-Normal Distribution. Also, it provides the random number generator for the mixture of Birbaum-Saunders model based on Skew-Normal distribution. Additionally, we incorporate the EM algorithm based on the assumption that the error term follows a finite mixture of Sinh-normal distributions.

Details

Package: bssn
Type: Package
Version: 1.5
Date: 2020-02-12
License: GPL (>=2)

Author(s)

Rocio Maehara [email protected] and Luis Benites [email protected]

References

Vilca, Filidor; Santana, L. R.; Leiva, Victor; Balakrishnan, N. (2011). Estimation of extreme percentiles in Birnbaum Saunders distributions. Computational Statistics & Data Analysis (Print), 55, 1665-1678.

Santana, Lucia; Vilca, Filidor; Leiva, Victor (2011). Influence analysis in skew-Birnbaum Saunders regression models and applications. Journal of Applied Statistics, 38, 1633-1649.

See Also

bssn, EMbssn, momentsbssn, ozone, reliabilitybssn, FMshnReg

Examples

#See examples for the bssnEM function linked above.

Birnbaum-Saunders model based on Skew-Normal distribution

Description

It provides the density, distribution function, quantile function, random number generator, likelihood function, moments and EM algorithm for Maximum Likelihood estimators for a given sample, all this for the three parameter Birnbaum-Saunders model based on Skew-Normal Distribution. Also, we have the random number generator for the mixture of Birbaum-Saunders model based on Skew-Normal distribution. Finally, the function mmmeth() is used to find the initial values for the parameters alpha and beta using modified-moment method.

Usage

dbssn(ti, alpha=0.5, beta=1, lambda=1.5)
pbssn(q,  alpha=0.5, beta=1, lambda=1.5)
qbssn(p,  alpha=0.5, beta=1, lambda=1.5)
rbssn(n,  alpha=0.5, beta=1, lambda=1.5)
rmixbssn(n,alpha,beta,lambda,pii)
mmmeth(ti)

Arguments

ti

vector of observations.

q

vector of quantiles.

p

vector of probabilities.

n

number of observations.

alpha

shape parameter.

beta

scale parameter.

lambda

skewness parameter.

pii

Are weights adding to 1. Each one of them (alpha, beta and lambda) must be a vector of length g if you want to generate a random numbers from a mixture distribution BSSN.

Details

If alpha, sigma or lambda are not specified they assume the default values of 0.5, 1 and 1.5, respectively, belonging to the Birnbaum-Saunders model based on Skew-Normal distribution denoted by BSSN(0.5,1,1.5)BSSN(0.5,1,1.5).

As discussed in Filidor et. al (2011) we say that a random variable T is distributed as an BSSN with shape parameter α>0\alpha>0, scale parameter β>0\beta>0 and skewness parameter λ\lambda in RR, if its probability density function (pdf) is given by

f(t)=2ϕ(a(t;α,β))Φ(λa(t;α,β))A(t;α,β),t>0f(t)=2\phi(a(t;\alpha,\beta))\Phi(\lambda a(t;\alpha,\beta))A(t;\alpha,\beta), t>0

where ϕ(.)\phi(.) and Φ(.)\Phi(.) are the standard normal density and cumulative distribution function respectively. Also a(t;α,β)=(1/α)(t/ββ/ta(t;\alpha,\beta)=(1/\alpha)(\sqrt{t/\beta}-\sqrt{\beta/t}) and A(t;α,β)=t3/2(t+β)/(2αβ1/2)A(t;\alpha,\beta)=t^{-3/2}(t+\beta)/(2\alpha \beta^{1/2})

Value

dbssn gives the density, pbssn gives the distribution function, qbssn gives the quantile function, rbssn generates a random sample and rmixbssn genrates a mixture random sample.

The length of the result is determined by n for rbssn, and is the maximum of the lengths of the numerical arguments for the other functions dbssn, pbssn and qbssn.

Author(s)

Rocio Maehara [email protected] and Luis Benites [email protected]

References

Vilca, Filidor; Santana, L. R.; Leiva, Victor; Balakrishnan, N. (2011). Estimation of extreme percentiles in Birnbaum Saunders distributions. Computational Statistics & Data Analysis (Print), 55, 1665-1678.

Santana, Lucia; Vilca, Filidor; Leiva, Victor (2011). Influence analysis in skew-Birnbaum Saunders regression models and applications. Journal of Applied Statistics, 38, 1633-1649.

See Also

EMbssn, momentsbssn, ozone, reliabilitybssn

Examples

## Not run: 
## Let's plot an Birnbaum-Saunders model based on Skew-Normal distribution!

## Density
 sseq <- seq(0,3,0.01)
 dens <- dbssn(sseq,alpha=0.2,beta=1,lambda=1.5)
 plot(sseq, dens,type="l", lwd=2,col="red", xlab="x", ylab="f(x)", main="BSSN Density function")

# Differing densities on a graph
# positive values of lambda
 y   <- seq(0,3,0.01)
 f1  <- dbssn(y,0.2,1,1)
 f2  <- dbssn(y,0.2,1,2)
 f3  <- dbssn(y,0.2,1,3)
 f4  <- dbssn(y,0.2,1,4)
 den <- cbind(f1,f2,f3,f4)

 matplot(y,den,type="l", col=c("deepskyblue4", "firebrick1", "darkmagenta", "aquamarine4"), ylab
 ="Density function",xlab="y",lwd=2,sub="(a)")

 legend(1.5,2.8,c("BSSN(0.2,1,1)", "BSSN(0.2,1,2)", "BSSN(0.2,1,3)","BSSN(0.2,1,4)"),
 col = c("deepskyblue4", "firebrick1", "darkmagenta", "aquamarine4"), lty=1:4,lwd=2,
 seg.len=2,cex=0.8,box.lty=0,bg=NULL)


#negative values of lambda
 y   <- seq(0,3,0.01)
 f1  <- dbssn(y,0.2,1,-1)
 f2  <- dbssn(y,0.2,1,-2)
 f3  <- dbssn(y,0.2,1,-3)
 f4  <- dbssn(y,0.2,1,-4)
 den <- cbind(f1,f2,f3,f4)

 matplot(y,den,type="l", col=c("deepskyblue4", "firebrick1", "darkmagenta", "aquamarine4"),
 ylab ="Density function",xlab="y",lwd=2,sub="(a)")
 legend(1.5,2.8,c("BSSN(0.2,1,-1)", "BSSN(0.2,1,-2)","BSSN(0.2,1,-3)", "BSSN(0.2,1,-4)"),
 col=c("deepskyblue4","firebrick1", "darkmagenta","aquamarine4"),lty=1:4,lwd=2,seg.len=2,
 cex=1,box.lty=0,bg=NULL)


## Distribution Function
 sseq <- seq(0.1,6,0.05)
 df   <- pbssn(q=sseq,alpha=0.75,beta=1,lambda=3)
 plot(sseq, df, type = "l", lwd=2, col="blue", xlab="x", ylab="F(x)",
 main = "BSSN Distribution  function")
 abline(h=1,lty=2)


#Inverse Distribution Function
 prob <- seq(0,1,length.out = 1000)
 idf  <- qbssn(p=prob,alpha=0.75,beta=1,lambda=3)
 plot(prob, idf, type="l", lwd=2, col="gray30", xlab="x", ylab =
 expression(F^{-1}~(x)), mgp=c(2.3,1,.8))
 title(main="BSSN Inverse Distribution function")
 abline(v=c(0,1),lty=2)


#Random Sample Histogram
 sample <- rbssn(n=10000,alpha=0.75,beta=1,lambda=3)
 hist(sample,breaks = 70,freq = FALSE,main="")
 title(main="Histogram and True density")
 sseq   <- seq(0,8,0.01)
 dens   <- dbssn(sseq,alpha=0.75,beta=1,lambda=3)
 lines(sseq,dens,col="red",lwd=2)


##Random Sample Histogram for Mixture of BSSN
alpha=c(0.55,0.25);beta=c(1,1.5);lambda=c(3,2);pii=c(0.3,0.7)
sample <- rmixbssn(n=1000,alpha,beta,lambda,pii)
hist(sample$y,breaks = 70,freq = FALSE,main="")
title(main="Histogram and True density")
temp   <- seq(min(sample$y), max(sample$y), length.out=1000)
lines(temp, (pii[1]*dbssn(temp, alpha[1], beta[1],lambda[1]))+(pii[2]*dbssn(temp, alpha[2]
, beta[2],lambda[2])), col="red", lty=3, lwd=3) # the theoretical density
lines(temp, pii[1]*dbssn(temp, alpha[1], beta[1],lambda[1]), col="blue", lty=2, lwd=3)
# the first component
lines(temp, pii[2]*dbssn(temp, alpha[2], beta[2],lambda[2]), col="green", lty=2, lwd=3)
# the second component

## End(Not run)

EM Algorithm Birnbaum-Saunders model based on Skew-Normal distribution

Description

Performs the EM algorithm for Birnbaum-Saunders model based on Skew-Normal distribution.

Usage

EMbssn(ti,alpha,beta,delta,initial.values=FALSE, loglik=F,accuracy=1e-8,
show.envelope="FALSE",iter.max=500)

Arguments

ti

Vector of observations.

alpha, beta, delta

Initial values.

initial.values

Logical; if TRUE, get the initial values for the parameters.

loglik

Logical; if TRUE, showvalue of the log-likelihood.

accuracy

The convergence maximum error.

show.envelope

Logical; if TRUE, show the simulated envelope for the fitted model.

iter.max

The maximum number of iterations of the EM algorithm

Value

The function returns a list with 11 elements detailed as

iter

Number of iterations.

alpha

Returns the value of the MLE of the shape parameter.

beta

Returns the value of the MLE of the scale parameter.

lambda

Returns the value of the MLE of the skewness parameter.

SE

Standard Errors of the ML estimates.

table

Table containing the ML estimates with the corresponding standard errors.

loglik

Log-likelihood.

AIC

Akaike information criterion.

BIC

Bayesian information criterion.

HQC

Hannan-Quinn information criterion.

time

processing time.

Author(s)

Rocio Maehara [email protected] and Luis Benites [email protected]

References

Vilca, Filidor; Santana, L. R.; Leiva, Victor; Balakrishnan, N. (2011). Estimation of extreme percentiles in Birnbaum Saunders distributions. Computational Statistics & Data Analysis (Print), 55, 1665-1678.

Santana, Lucia; Vilca, Filidor; Leiva, Victor (2011). Influence analysis in skew-Birnbaum Saunders regression models and applications. Journal of Applied Statistics, 38, 1633-1649.

See Also

bssn, EMbssn, momentsbssn, ozone, reliabilitybssn

Examples

## Not run: 
#Using the ozone data

data(ozone)
attach(ozone)

#################################
#The model
 ti        <- dailyozonelevel

#Initial values for the parameters
 initial   <- mmmeth(ti)
 alpha0    <- initial$alpha0ini
 beta0     <- initial$beta0init
 lambda0   <- 0
 delta0    <- lambda0/sqrt(1+lambda0^2)

#Estimated parameters of the model (by default)
 est_param <- EMbssn(ti,alpha0,beta0,delta0,loglik=T,
 accuracy = 1e-8,show.envelope = "TRUE", iter.max=500)

#ML estimates
 alpha     <- est_param$res$alpha
 beta      <- est_param$res$beta
 lambda    <- est_param$res$lambda


#########################################
#A simple output example

---------------------------------------------------------
Birnbaum-Saunders model based on Skew-Normal distribution
---------------------------------------------------------

Observations = 116
-----------
Estimates
-----------

       Estimate Std. Error z value Pr(>|z|)
alpha   1.26014    0.23673 5.32311  0.00000
beta   14.65730    4.01984 3.64624  0.00027
lambda  1.06277    0.54305 1.95706  0.05034
------------------------
Model selection criteria
------------------------

        Loglik   AIC   BIC   HQC
Value -542.768 4.705 4.741 4.719
-------
Details
-------

Iterations = 415
Processing time = 0.4283214 secs
Convergence = TRUE

## End(Not run)

Enzymatic activity in the blood

Description

These data correspond to representing the metabolism of carcinogenic substances among 245 unrelated individuals.

Usage

data(enzyme)

Format

enzyme is a data frame with 245 cases (rows).

Details

For more information about dataset see Bechtel et al. (1993).

Source

Bechtel, Y., Bonaiti-Pellie, C., Poisson, N., Magnette, J. and Bechtel, P. (1993). A population and family study of n-acetyltransferase using caffeine urinary metabolites. Clinical Pharmacology and Therapeutics, 54, 134-141.


Linear regression models using finite mixture of Sinh-normal distribution

Description

Performs the EM-type algorithm with conditonal maximation to perform maximum likelihood inference of the parameters of the proposed model based on the assumption that the error term follows a finite mixture of Sinh-normal distributions.

Usage

FMshnReg(y, x1, alpha = NULL, Abetas = NULL, medj=NULL,
pii = NULL, g = NULL, get.init = TRUE,algorithm = "K-means",
accuracy = 10^-6, show.envelope="FALSE", iter.max = 100)

Arguments

y

the response matrix (dimension nx1).

x1

Matrix or vector of covariates.

alpha

Value of the shape parameter for the EM algorithm. Each of them must be a vector of length g. (the algorithm considers the number of components to be adjusted based on the size of these vectors).

Abetas

Parameters of vector regression dimension (p+1)(p + 1) include intercept.

medj

a list of g arguments of vectors of values (dimension p) for the location parameters.

pii

Value for the EM algorithm. Each of them must be a vector of length g. (the algorithm considers the number of components to be adjusted based on the size of these vectors).

g

The number of cluster to be considered in fitting.

get.init

if TRUE, the initial values are generated via k-means.

algorithm

clustering procedure of a series of vectors according to a criterion. The clustering algorithms may classified in 4 main categories: exclusive, overlapping, hierarchical and probabilistic.

accuracy

The convergence maximum error.

show.envelope

Logical; if TRUE, show the simulated envelope for the fitted model.

iter.max

The maximum number of iterations of the EM algorithm

Value

The function returns a list with 10 elements detailed as

iter

Number of iterations.

criteria

Attained criteria value.

convergence

Convergence reached or not.

SE

Standard Error estimates, if the output shows NA the function does not provide the standard error for this parameter.

table

Table containing the inference for the estimated parameters.

LK

log-likelihood.

AIC

Akaike information criterion.

BIC

Bayesian information criterion.

EDC

Efficient Determination criterion.

time

Processing time.

Author(s)

Rocio Maehara [email protected] and Luis Benites [email protected]

References

Maehara, R. and Benites, L. (2020). Linear regression models using finite mixture of Sinh-normal distribution. In Progress.

Bartolucci, F. and Scaccia, L. (2005). The use of mixtures for dealing with non-normal regression errors, Computational Statistics & Data Analysis 48(4): 821-834.

Examples

## Not run: 
#Using the AIS data

library(FMsmsnReg)
data(ais)

#################################
#The model
x1    <- cbind(1,ais$SSF,ais$Ht)
y     <- ais$Bfat

library(ClusterR) #This library is useful for using the k-medoids algorithm.

FMshnReg(y, x1, get.init = TRUE, g=2, algorithm="k-medoids",
accuracy = 10^-6, show.envelope="FALSE", iter.max = 1000)

#########################################
#A simple output example

------------------------------------------------------------
Finite Mixture of Sinh Normal Regression Model
------------------------------------------------------------

Observations = 202

-----------
Estimates
-----------

       Estimate      SE
alpha1  0.81346 0.10013
alpha2  3.04894 0.32140
beta0  15.08998 1.70024
beta1   0.17708 0.00242
beta2  -0.07687 0.00934
mu1    -0.25422 0.18069
mu2     0.37944 0.38802
pii1    0.59881 0.41006

------------------------
Model selection criteria
------------------------

        Loglik    AIC     BIC     EDC
Value -355.625 721.25 737.791 725.463

-------
Details
-------

Convergence reached? = TRUE
EM iterations = 39 / 1000
Criteria = 6.58e-07
Processing time = 0.725559 secs

## End(Not run)

Moments for the Birnbaum-Saunders model based on Skew-Normal distribution

Description

Mean, variance, skewness and kurtosis for the Birnbaum-Saunders model based on Skew-Normal distribution defined in Filidor et. al (2011).

Usage

meanbssn(alpha=0.5,beta=1,lambda=1.5)
varbssn(alpha=0.5,beta=1,lambda=1.5)
skewbssn(alpha=0.5,beta=1,lambda=1.5)
kurtbssn(alpha=0.5,beta=1,lambda=1.5)

Arguments

alpha

shape parameter α\alpha.

beta

scale parameter β\beta.

lambda

skewness parameter λ\lambda.

Value

meanbssn gives the mean, varbssn gives the variance, skewbssn gives the skewness, kurtbssn gives the kurtosis.

Author(s)

Rocio Maehara [email protected] and Luis Benites [email protected]

References

Vilca, Filidor; Santana, L. R.; Leiva, Victor; Balakrishnan, N. (2011). Estimation of extreme percentiles in Birnbaum Saunders distributions. Computational Statistics & Data Analysis (Print), 55, 1665-1678.

Santana, Lucia; Vilca, Filidor; Leiva, Victor (2011). Influence analysis in skew-Birnbaum Saunders regression models and applications. Journal of Applied Statistics, 38, 1633-1649.

See Also

bssn, EMbssn, momentsbssn, ozone, reliabilitybssn

Examples

## Let's compute some moments for a Birnbaum-Saunders model based on Skew normal Distribution.
# The well known mean, variance, skewness and kurtosis
meanbssn(alpha=0.5,beta=1,lambda=1.5)
varbssn(alpha=0.5,beta=1,lambda=1.5)
skewbssn(alpha=0.5,beta=1,lambda=1.5)
kurtbssn(alpha=0.5,beta=1,lambda=1.5)

Daily ozone level measurements

Description

These data correspond to daily ozone level measurements (in ppb=ppmx1000ppb=ppm x 1000) in New York in May-September, 1973, from the New York State Department of Conservation.

Usage

data(ozone)

Format

ozone is a data frame with 116 cases (rows).

Details

For a complete description of various distributions applied to data concentration of air pollutants see Gokhale and Khare (2004).

Source

Leiva, V., Barros, M., Paula, G. e Sanhueza, A. (2007). Generalized BirnbaumSaunders distribution applied to air pollutant concentration. Environmetrics, 19, 235-249.

Nadarajah, S. (2007). A truncated inverted beta distribution with application to air pollution data. Stoch. Environ. Res. Risk. Assess., 22, 285-289.

Gokhale, S. e Khare, M. (2004) A review of deterministic, stochastic and hybrid vehicular exhaust emission models International. J. Transp. Manag., 2, 59-74.


Reliability Function for the Birnbaum-Saunders model based on Skew-Normal distribution

Description

Two useful descriptors in reliability analysis are the reliability function (rf), and the failure rate (fr) function or hazard function. For a non-negative random variable tt with pdf f(t)f(t) (and cdf F(t)F(t)), its distribution can be characterized equally in terms of the rf, or of the fr, which are respectively defined by R(t)=1F(t)R(t)=1-F(t), and h(t)=f(t)/R(t)h(t)=f(t)/R(t), for t>0t>0,and 0<R(t)<10<R(t)<1.

Usage

Rebssn(ti,alpha=0.5,beta=1,lambda=1.5)
Fbssn(ti,alpha=0.5,beta=1,lambda=1.5)

Arguments

ti

dataset.

alpha

shape parameter α\alpha.

beta

scale parameter β\beta.

lambda

skewness parameter λ\lambda.

Value

Rbssn gives the reliability function, Fbssn gives the failure rate or hazard function.

Author(s)

Rocio Maehara [email protected] and Luis Benites [email protected]

References

Leiva, V., Vilca-Labra, F. E., Balakrishnan, N. e Sanhueza, A. (2008). A skewed sinh-normal distribution and its properties and application to air pollution. Comm. Stat. Theoret. Methods. Submetido.

Guiraud, P., Leiva, V., Fierro, R. (2009). A non-central version of the Birnbaum-Saunders distribution for reliability analysis. IEEE Transactions on Reliability 58, 152-160.

See Also

bssn, EMbssn, momentsbssn, ozone, Rebssn

Examples

## Let's compute some realiability functions for a Birnbaum-Saunders model based on
## Skew normal Distribution for different values of the shape parameter.

ti  <- seq(0,2,0.01)
f1  <- Rebssn(ti,0.75,1,1)
f2  <- Rebssn(ti,1,1,1)
f3  <- Rebssn(ti,1.5,1,1)
f4  <- Rebssn(ti,2,1,1)
den <- cbind(f1,f2,f3,f4)

matplot(ti,den,type="l", col=c("deepskyblue4","firebrick1","darkmagenta","aquamarine4"),
ylab="S(t)", xlab="t",lwd=2)
legend(1.5,1,c(expression(alpha==0.75), expression(alpha==1), expression(alpha==1.5),
expression(alpha==2)),col= c("deepskyblue4","firebrick1","darkmagenta","aquamarine4"),
lty=1:4,lwd=2,seg.len=2,cex=0.9,box.lty=0,bg=NULL)


## Let's compute some hazard functions for a Birnbaum Saunders model based on
## Skew normal Distribution for different values of the skewness parameter.

ti  <- seq(0,2,0.01)
f1  <- Fbssn(ti,0.5,1,-1)
f2  <- Fbssn(ti,0.5,1,-2)
f3  <- Fbssn(ti,0.5,1,-3)
f4  <- Fbssn(ti,0.5,1,-4)
den <- cbind(f1,f2,f3,f4)
matplot(ti,den,type = "l", col = c("deepskyblue4","firebrick1", "darkmagenta", "aquamarine4"),
ylab = "h(t)" , xlab="t",lwd=2)
legend(0.1,23, c(expression(lambda==-1), expression(lambda==-2), expression(lambda == -3),
expression(lambda == -4)), col = c("deepskyblue4", "firebrick1", "darkmagenta","aquamarine4"),
lty=1:4,lwd=2,seg.len=2,cex=0.9,box.lty=1,bg=NULL)