Package 'bivgeom'

Title: Roy's Bivariate Geometric Distribution
Description: Implements Roy's bivariate geometric model (Roy (1993) <doi:10.1006/jmva.1993.1065>): joint probability mass function, distribution function, survival function, random generation, parameter estimation, and more.
Authors: Alessandro Barbiero
Maintainer: Alessandro Barbiero <[email protected]>
License: GPL
Version: 1.0
Built: 2024-12-01 08:51:13 UTC
Source: CRAN

Help Index


Roy's Bivariate Geometric Distribution

Description

Implements Roy's bivariate geometric model (Roy (1993) <doi:10.1006/jmva.1993.1065>): joint probability mass function, distribution function, survival function, random generation, parameter estimation, and more.

Details

The DESCRIPTION file:

Package: bivgeom
Type: Package
Title: Roy's Bivariate Geometric Distribution
Version: 1.0
Date: 2018-10-17
Author: Alessandro Barbiero
Maintainer: Alessandro Barbiero <[email protected]>
Imports: methods, stats, utils, bbmle, copula
Description: Implements Roy's bivariate geometric model (Roy (1993) <doi:10.1006/jmva.1993.1065>): joint probability mass function, distribution function, survival function, random generation, parameter estimation, and more.
License: GPL
NeedsCompilation: no
Packaged: 2018-10-17 16:23:28 UTC; admin
Repository: CRAN
Date/Publication: 2018-10-26 15:20:06 UTC
Config/pak/sysreqs: libgsl0-dev

Index of help topics:

EyxbivgeomRoy           Conditional moment
FbivgeomRoy             Joint distribution function
FyxbivgeomRoy           Conditional distribution
RelbivgeomRoy           Reliability parameter
S.n                     Empirical joint survival function
SbivgeomRoy             Joint survival function
bivgeom-package         Roy's Bivariate Geometric Distribution
corbivgeomRoy           Linear correlation
dbivgeomRoy             Joint probability mass function
estbivgeomRoy           Parameter estimation
lambda1Roy              Bivariate failure rates
lambda2Roy              Bivariate failure rate
loglikgeomRoy           Log-likelihood function
minuslogRoy             Log-likelihood function
rbivgeomRoy             Pseudo-random generation

Author(s)

Alessandro Barbiero

Maintainer: Alessandro Barbiero ([email protected])

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

Barbiero, A. (2018) Properties and estimation of a bivariate geometric model with locally constant failure rates, submitted

See Also

dbivgeomRoy, rbivgeomRoy, estbivgeomRoy, FbivgeomRoy

Examples

#####################################
#### MONTE CARLO SIMULATION PLAN ####
#####################################
# setting the parameters' values
theta1 <- 0.3
theta2 <- 0.7
theta3 <- 0.6
N <- 20       # number of Monte Carlo runs
n <- 100      # sample size
# arranging the array containig the simulation results
# N runs, 7 methods, 3 estimates
h <- array(0,c(N,7,3))
# setting the seed 
set.seed(12345)
# function for handling missing values 
# when computing the mean and standard deviation of the estimates:
meanrm <- function(x){mean(x,na.rm=TRUE)}
sdrm <- function(x){sd(x,na.rm=TRUE)}
colnames <- c("ML","MMP","MM1","MM2","MM3","MM4","LS")
dimnames(h)[[2]] <- colnames
# Monte Carlo simulation:
for(i in 1:N)
{
d <- rbivgeomRoy(n,theta1,theta2,theta3)
cat("MC run #",i,"\n")
x<-d[,1]
y<-d[,2]
# implementing all the estimation methods 
# and saving the point estimates in the array
h[i,1,] <- estbivgeomRoy(x, y, "ML")
h[i,2,] <- estbivgeomRoy(x, y, "MMP")
h[i,3,] <- estbivgeomRoy(x, y, "MM1")
h[i,4,] <- estbivgeomRoy(x, y, "MM2")
h[i,5,] <- estbivgeomRoy(x, y, "MM3")
h[i,6,] <- estbivgeomRoy(x, y, "MM4")
h[i,7,] <- estbivgeomRoy(x, y, "LS")
}
# printing MC expected values and standard errors
# for each of the proposed estimation methods
cat("hattheta1:","\n")
cbind(mean=apply(h,c(2,3),meanrm)[,1],se=apply(h,c(2,3),sdrm)[,1]) 
cat("hattheta2:","\n")
cbind(mean=apply(h,c(2,3),meanrm)[,2],se=apply(h,c(2,3),sdrm)[,2]) 
cat("hattheta3:","\n")
cbind(mean=apply(h,c(2,3),meanrm)[,3],se=apply(h,c(2,3),sdrm)[,3]) 
# boxplots of MC distribution of the estimators of theta3
boxplot(h[,,3])
abline(h=theta3, lty=3)

Linear correlation

Description

Linear correlation for Roy's bivariate geometric model

Usage

corbivgeomRoy(theta1, theta2, theta3)

Arguments

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

Value

the value of Pearson's linear correlation - see Barbiero (2018). The linear correlation for Roy's bivariate geometric distribution is negative (or null, for θ3=1\theta_3=1) for any feasible choice of its parameters

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

Barbiero, A. (2018) Properties and estimation of a bivariate geometric model with locally constant failure rates, submitted

See Also

dbivgeomRoy

Examples

corbivgeomRoy(0.3,0.7,0.5)

Joint probability mass function

Description

Joint probability mass function for Roy's bivariate geometric model

Usage

dbivgeomRoy(x, y, theta1, theta2, theta3)

Arguments

x

vector of values for the first variable XX

y

vector of values for the second variable YY

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

Value

Value of the probability p(x,y):=P(X=x,Y=y)p(x,y):=P(X=x,Y=y).

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

FbivgeomRoy

Examples

dbivgeomRoy(x=2, y=0, theta1=0.7, theta2=0.2, theta3=0.8)
dbivgeomRoy(0:5, y=0, theta1=0.7, theta2=0.2, theta3=0.8)
# these are p(0,0), p(1,0), ..., p(5,0)
dbivgeomRoy(0:2, 1:3, theta1=0.7, theta2=0.2, theta3=0.8)
# these are p(0,1), p(1,2), p(2,3)

Parameter estimation

Description

Parameter estimation for Roy's bivariate geometric model

Usage

estbivgeomRoy(x, y, method = "LS")

Arguments

x

vector of observations from the first variable XX

y

vector of observations from the first variable yy, same length as x

method

One of the possible estimation methods: "ML" (maximum likelihood), "LS" (least squares), "MMP" (method of moment and poroportion), "M1", "M2", "M3", and "M4" (several variants of the method of moments)

Value

a vector of length 3 containing the estimates of theta1theta_1, theta2theta_2, and theta3theta_3

Author(s)

Alessandro Barbiero

References

Barbiero, A. (2018) Properties and estimation of a bivariate geometric model with locally constant failure rates, submitted

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

dbivgeomRoy, minuslogRoy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
# random sample of size n=1000:
set.seed(12345)
n <- 1000
d <- rbivgeomRoy(n, theta1, theta2, theta3)
# parameter estimation, using the different proposed methods:
hattheta <- estbivgeomRoy(d[,1], d[,2], "ML")
hattheta # MLEs
estbivgeomRoy(d[,1], d[,2], "LS")
estbivgeomRoy(d[,1], d[,2], "MMP")

Conditional moment

Description

Conditional moment of YY given X=xX=x for Roy's bivariate geomtric model

Usage

EyxbivgeomRoy(theta1, theta2, theta3, x)

Arguments

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

x

value of the conditioning variable XX

Value

Value of the conditional moment of YY given X=xX=x

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

FyxbivgeomRoy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
EyxbivgeomRoy(theta1, theta2, theta3, 2)

Joint distribution function

Description

Joint cumulative distribution function for Roy's bivariate geometric model

Usage

FbivgeomRoy(x, y, theta1, theta2, theta3)

Arguments

x

vector of values for the first variable XX

y

vector of values for the second variable YY

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

Value

The probability F(x,y):=P(Xx,Yx)F(x,y):=P(X\leq x,Y\leq x)

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

dbivgeomRoy, SbivgeomRoy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
# probability that X<=2 and Y<=3:
FbivgeomRoy(2, 3, theta1, theta2, theta3)

Conditional distribution

Description

Conditional distribution function of YY given X=xX=x

Usage

FyxbivgeomRoy(y, theta1, theta2, theta3, x)

Arguments

y

vector of observations from YY

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

x

value of the conditioning variable XX

Value

The value of the conditional cumulative distribution function FYxF_{Y|x} in yy. Used in rbivgeomRoy for conditional sampling

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

EyxbivgeomRoy, rbivgeomRoy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
# probability that Y<=3 given that X=2:
FyxbivgeomRoy(3, theta1, theta2, theta3, 2)
# the unconditional probability would be
pgeom(3, 1-theta2) # i.e. a geometric distribution with parameter 1-theta2

Bivariate failure rates

Description

Bivariate failure rate λ1\lambda_1

Usage

lambda1Roy(x, y, theta1, theta2, theta3)

Arguments

x

observation from the first variable

y

observation from the second variable

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

Details

It is defined as P(X=x,Yy)/P(Xx,Yy)P(X=x,Y\geq y)/P(X\geq x,Y\geq y). For this model, λ1(x,y)=1θ1θ3y\lambda_1(x,y)=1-\theta_1\theta_3^y

Value

Value of the bivariate failure rate λ1\lambda_1 for Roy's bivariate geometric model (Roy, 1993)

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

lambda2Roy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
# bivariate failure rate lambda1
# computed in x=1, y=2
x <- 1
y <- 2
lambda1Roy(x,y,theta1,theta2,theta3)

Bivariate failure rate

Description

Bivariate failure rate λ2\lambda_2

Usage

lambda2Roy(x, y, theta1, theta2, theta3)

Arguments

x

observation from the first variable

y

observation from the second variable

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

Details

It is defined as P(Xx,Y=y)/P(Xx,Yy)P(X\geq x,Y=y)/P(X\geq x,Y\geq y). For this model, λ2(x,y)=1θ2θ3x\lambda_2(x,y)=1-\theta_2\theta_3^x

Value

Value of the bivariate failure rate λ2\lambda_2 for Roy's bivariate geometric model (Roy, 1993)

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

lambda1Roy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
# bivariate failure rate lambda 2
# computed in x=1, y=2
x <- 1
y <- 2
lambda2Roy(x,y,theta1,theta2,theta3)

Log-likelihood function

Description

Negative log-likelihood function for Roy's bivariate geometric model

Usage

loglikgeomRoy(par, x, y)

Arguments

par

a vector containing the values of the three parameters θ1\theta_1, θ2\theta_2, and θ3\theta_3

x

numeric vector of sample xx-values (non-negative integers)

y

numeric vector of sample xx-values (non-negative integers), same length as x

Value

Value of the negative log-likelihood function

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

dbivgeomRoy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
# random sample of size n=1000:
set.seed(12345)
n <- 1000
d <- rbivgeomRoy(n, theta1, theta2, theta3)
# parameter estimation, using the different proposed methods:
hattheta <- estbivgeomRoy(d[,1], d[,2], "ML")
loglikgeomRoy(hattheta, x=d[,1], y=d[,2])
# negative value of the (maximized) log-likelihood function

Log-likelihood function

Description

Log-likelihood function (with minus sign) for Roy's bivariate geometric model

Usage

minuslogRoy(x, y, theta1 = 0.5, theta2 = 0.5, theta3 = 1)

Arguments

x

a vector of observed values (non-negative integers)

y

a vector of observed values (non-negative integers) of the same length as x

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

Value

The value of the log-likelihood function, changed in sign

Note

Just to be used inside the estbivgeomRoy function

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

estbivgeomRoy


Pseudo-random generation

Description

Generation of pseudo-random values from Roy's bivariate geometric model

Usage

rbivgeomRoy(n, theta1, theta2, theta3)

Arguments

n

a positive integer, corresponding to the sample size

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

Value

A n×2n\times 2 numeric matrix containing the bivariate sample values

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

dbivgeomRoy, FbivgeomRoy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
# random sample of size n=1000:
set.seed(12345)
n <- 1000
d <- rbivgeomRoy(n, theta1, theta2, theta3)
# joint frequency distribution:
table(d[,1],d[,2])

Reliability parameter

Description

Stress-strength reliability parameter RR for Roy's bivariate geometric model

Usage

RelbivgeomRoy(theta1, theta2, theta3)

Arguments

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

Value

The probability R:=P(XY)R:=P(X\leq Y) for Roy's bivariate geometric model - see Barbiero (2018) for its computation

Author(s)

Alessandro Barbiero

References

Barbiero, A. (2018) Properties and estimation of a bivariate geometric model with locally constant failure rates, submitted

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

dbivgeomRoy, FbivgeomRoy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
RelbivgeomRoy(theta1, theta2, theta3)
# theoretical stress-strength reliability parameter R=P(X<=Y)

Empirical joint survival function

Description

Empirical joint survival function

Usage

S.n(x, X)

Arguments

x

matrix with two columns of non-negative integer values where the empirical joint survival function is computed

X

matrix with two columns corresponding to the full observed sample

Value

value of the empirical joint survival function S^X(x)\hat{S}_X(x)

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

estbivgeomRoy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
set.seed(12345)
n <- 1000
d <- rbivgeomRoy(n, theta1, theta2, theta3)
S.n(cbind(1,1),d) # empirical sf
# compare it with the theoretical
SbivgeomRoy(1,1,theta1,theta2,theta3)

Joint survival function

Description

Joint survival function for Roy's bivariate geometric model

Usage

SbivgeomRoy(x, y, theta1, theta2, theta3)

Arguments

x

vector of observations from the first variable XX

y

vector of observations from the second variable YY (same length as x)

theta1

paramater θ1\theta_1

theta2

paramater θ2\theta_2

theta3

paramater θ3\theta_3

Value

The probability P(Xx,YyP(X\geq x, Y\geq y. For this model it is equal to S(x,y)=θ1xθ2yθ3xyS(x,y)=\theta_1^x\theta_2^y\theta_3^{xy}

Author(s)

Alessandro Barbiero

References

Roy, D. (1993) Reliability measures in the discrete bivariate set-up and related characterization results for a bivariate geometric distribution, Journal of Multivariate Analysis 46(2), 362-373.

See Also

FbivgeomRoy

Examples

theta1 <- 0.5
theta2 <- 0.7
theta3 <- 0.9
# probability that X>=2 and Y>=3:
SbivgeomRoy(2, 3, theta1, theta2, theta3)