| 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: | 2026-06-07 07:58:58 UTC |
| Source: | https://github.com/cran/bivgeom |
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.
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 |
| Config/pak/sysreqs: | libgsl0-dev |
| Repository: | https://alessandro-barbiero.r-universe.dev |
| Date/Publication: | 2018-10-26 14:20:06 UTC |
| RemoteUrl: | https://github.com/cran/bivgeom |
| RemoteRef: | HEAD |
| RemoteSha: | 3e6d998a9a17b701f396976cacde302c2a879663 |
Index of help topics:
bivgeom-package Roy's Bivariate Geometric Distribution corbivgeomRoy Linear correlation dbivgeomRoy Joint probability mass function estbivgeomRoy Parameter estimation EyxbivgeomRoy Conditional moment FbivgeomRoy Joint distribution function FyxbivgeomRoy Conditional distribution lambda1Roy Bivariate failure rates lambda2Roy Bivariate failure rate loglikgeomRoy Log-likelihood function minuslogRoy Log-likelihood function rbivgeomRoy Pseudo-random generation RelbivgeomRoy Reliability parameter S.n Empirical joint survival function SbivgeomRoy Joint survival function
Alessandro Barbiero
Maintainer: Alessandro Barbiero ([email protected])
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
dbivgeomRoy, rbivgeomRoy, estbivgeomRoy, FbivgeomRoy
##################################### #### 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)##################################### #### 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 for Roy's bivariate geometric model
corbivgeomRoy(theta1, theta2, theta3)corbivgeomRoy(theta1, theta2, theta3)
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
the value of Pearson's linear correlation - see Barbiero (2018). The linear correlation for Roy's bivariate geometric distribution is negative (or null, for ) for any feasible choice of its parameters
Alessandro Barbiero
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
corbivgeomRoy(0.3,0.7,0.5)corbivgeomRoy(0.3,0.7,0.5)
Joint probability mass function for Roy's bivariate geometric model
dbivgeomRoy(x, y, theta1, theta2, theta3)dbivgeomRoy(x, y, theta1, theta2, theta3)
x |
vector of values for the first variable |
y |
vector of values for the second variable |
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
Value of the probability .
Alessandro Barbiero
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.
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)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 for Roy's bivariate geometric model
estbivgeomRoy(x, y, method = "LS")estbivgeomRoy(x, y, method = "LS")
x |
vector of observations from the first variable |
y |
vector of observations from the first variable |
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) |
a vector of length 3 containing the estimates of , , and
Alessandro Barbiero
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.
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")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 of given for Roy's bivariate geomtric model
EyxbivgeomRoy(theta1, theta2, theta3, x)EyxbivgeomRoy(theta1, theta2, theta3, x)
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
x |
value of the conditioning variable |
Value of the conditional moment of given
Alessandro Barbiero
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.
theta1 <- 0.5 theta2 <- 0.7 theta3 <- 0.9 EyxbivgeomRoy(theta1, theta2, theta3, 2)theta1 <- 0.5 theta2 <- 0.7 theta3 <- 0.9 EyxbivgeomRoy(theta1, theta2, theta3, 2)
Joint cumulative distribution function for Roy's bivariate geometric model
FbivgeomRoy(x, y, theta1, theta2, theta3)FbivgeomRoy(x, y, theta1, theta2, theta3)
x |
vector of values for the first variable |
y |
vector of values for the second variable |
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
The probability
Alessandro Barbiero
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.
theta1 <- 0.5 theta2 <- 0.7 theta3 <- 0.9 # probability that X<=2 and Y<=3: FbivgeomRoy(2, 3, theta1, theta2, theta3)theta1 <- 0.5 theta2 <- 0.7 theta3 <- 0.9 # probability that X<=2 and Y<=3: FbivgeomRoy(2, 3, theta1, theta2, theta3)
Conditional distribution function of given
FyxbivgeomRoy(y, theta1, theta2, theta3, x)FyxbivgeomRoy(y, theta1, theta2, theta3, x)
y |
vector of observations from |
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
x |
value of the conditioning variable |
The value of the conditional cumulative distribution function in . Used in rbivgeomRoy for conditional sampling
Alessandro Barbiero
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.
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-theta2theta1 <- 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 rate
lambda1Roy(x, y, theta1, theta2, theta3)lambda1Roy(x, y, theta1, theta2, theta3)
x |
observation from the first variable |
y |
observation from the second variable |
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
It is defined as . For this model,
Value of the bivariate failure rate for Roy's bivariate geometric model (Roy, 1993)
Alessandro Barbiero
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.
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)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
lambda2Roy(x, y, theta1, theta2, theta3)lambda2Roy(x, y, theta1, theta2, theta3)
x |
observation from the first variable |
y |
observation from the second variable |
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
It is defined as . For this model,
Value of the bivariate failure rate for Roy's bivariate geometric model (Roy, 1993)
Alessandro Barbiero
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.
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)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)
Negative log-likelihood function for Roy's bivariate geometric model
loglikgeomRoy(par, x, y)loglikgeomRoy(par, x, y)
par |
a vector containing the values of the three parameters |
x |
numeric vector of sample |
y |
numeric vector of sample |
Value of the negative log-likelihood function
Alessandro Barbiero
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.
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 functiontheta1 <- 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 (with minus sign) for Roy's bivariate geometric model
minuslogRoy(x, y, theta1 = 0.5, theta2 = 0.5, theta3 = 1)minuslogRoy(x, y, theta1 = 0.5, theta2 = 0.5, theta3 = 1)
x |
a vector of observed values (non-negative integers) |
y |
a vector of observed values (non-negative integers) of the same length as |
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
The value of the log-likelihood function, changed in sign
Just to be used inside the estbivgeomRoy function
Alessandro Barbiero
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.
Generation of pseudo-random values from Roy's bivariate geometric model
rbivgeomRoy(n, theta1, theta2, theta3)rbivgeomRoy(n, theta1, theta2, theta3)
n |
a positive integer, corresponding to the sample size |
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
A numeric matrix containing the bivariate sample values
Alessandro Barbiero
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.
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])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])
Stress-strength reliability parameter for Roy's bivariate geometric model
RelbivgeomRoy(theta1, theta2, theta3)RelbivgeomRoy(theta1, theta2, theta3)
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
The probability for Roy's bivariate geometric model - see Barbiero (2018) for its computation
Alessandro Barbiero
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.
theta1 <- 0.5 theta2 <- 0.7 theta3 <- 0.9 RelbivgeomRoy(theta1, theta2, theta3) # theoretical stress-strength reliability parameter R=P(X<=Y)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
S.n(x, X)S.n(x, X)
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 of the empirical joint survival function
Alessandro Barbiero
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.
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)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 for Roy's bivariate geometric model
SbivgeomRoy(x, y, theta1, theta2, theta3)SbivgeomRoy(x, y, theta1, theta2, theta3)
x |
vector of observations from the first variable |
y |
vector of observations from the second variable |
theta1 |
paramater |
theta2 |
paramater |
theta3 |
paramater |
The probability . For this model it is equal to
Alessandro Barbiero
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.
theta1 <- 0.5 theta2 <- 0.7 theta3 <- 0.9 # probability that X>=2 and Y>=3: SbivgeomRoy(2, 3, theta1, theta2, theta3)theta1 <- 0.5 theta2 <- 0.7 theta3 <- 0.9 # probability that X>=2 and Y>=3: SbivgeomRoy(2, 3, theta1, theta2, theta3)