Package {BivGeo}


Type: Package
Title: Basu-Dhar Bivariate Geometric Distribution and Regression
Version: 3.0.0
Maintainer: Ricardo Puziol de Oliveira <rpuziol.oliveira@gmail.com>
Description: Provides probability mass, cumulative distribution and joint survival functions, random generation, theoretical moments, method-of-moments and maximum likelihood estimation, and Bayesian inference using Metropolis algorithms for the Basu-Dhar bivariate geometric distribution, including regression with covariates, complete and right-censored discrete event times, configurable prior distributions, model predictions, residual analysis, joint goodness-of-fit assessment and MCMC convergence diagnostics; see de Oliveira and Achcar (2018) <doi:10.1285/i20705948v11n1p108>.
Depends: R (≥ 3.6.0)
Imports: stats, graphics, utils
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
URL: https://doi.org/10.1285/i20705948v11n1p108
RoxygenNote: 7.3.3
Encoding: UTF-8
NeedsCompilation: no
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Packaged: 2026-11-16 02:15:45 UTC; rpuzi
Author: Ricardo Puziol de Oliveira [aut, cre], Jorge Alberto Achcar [aut]
Repository: CRAN
Date/Publication: 2026-11-16 08:50:49 UTC

Methods for Basu-Dhar Maximum-Likelihood Fits

Description

Extracts maximum-likelihood estimates, their covariance matrix, log-likelihood, sample size, Wald confidence intervals and summary output from bivgeo_fit objects.

Usage

## S3 method for class 'bivgeo_fit'
coef(object, ...)

## S3 method for class 'bivgeo_fit'
vcov(object, ...)

## S3 method for class 'bivgeo_fit'
logLik(object, ...)

## S3 method for class 'bivgeo_fit'
nobs(object, ...)

## S3 method for class 'bivgeo_fit'
summary(object, ...)

## S3 method for class 'summary.bivgeo_fit'
print(x, ...)

## S3 method for class 'bivgeo_fit'
print(x, ...)

## S3 method for class 'bivgeo_fit'
confint(object, parm, level = 0.95, ...)

Arguments

object

A fitted bivgeo_fit object.

...

Additional arguments for S3 compatibility.

x

Fitted model or summary object.

parm

Optional coefficient names or indices.

level

Confidence level between zero and one.

Details

Maximum-likelihood methods for Basu-Dhar fits

Methods for extracting parameter estimates, covariance matrices, log-likelihoods, observation counts, confidence intervals and summaries.

For interior estimates, a two-sided Wald interval has the form

\widehat\theta_j\mathbin{\pm} z_{1-\alpha/2} \sqrt{\widehat{\mathrm{Var}}(\widehat\theta_j)}.

The covariance matrix is based on the inverse observed Hessian. These approximations may be unreliable near boundaries, especially when \theta_{12}=1 is selected. The coefficient scale here is the original \theta scale, unlike logistic regression coefficients.

Value

coef() returns parameter estimates on the theta scale; vcov() returns their covariance matrix; logLik() returns an object of class logLik; nobs() returns the sample size; confint() returns confidence interval limits. summary() returns fitted-model summaries.

References

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

data("BivGeoFaithful", package = "BivGeo")
  fit <- fit_bivgeo(as.matrix(BivGeoFaithful[c("X", "Y")]))
  coef(fit)
  vcov(fit)
  logLik(fit)
  nobs(fit)
  summary(fit)
  confint(fit)

Methods for Basu-Dhar Regression Fits

Description

Extracts regression coefficients, their covariance matrix, log-likelihood, sample size and Wald confidence intervals from bivgeo_reg objects.

Usage

## S3 method for class 'bivgeo_reg'
coef(object, ...)

## S3 method for class 'bivgeo_reg'
vcov(object, ...)

## S3 method for class 'bivgeo_reg'
logLik(object, ...)

## S3 method for class 'bivgeo_reg'
nobs(object, ...)

## S3 method for class 'bivgeo_reg'
summary(object, ...)

## S3 method for class 'summary.bivgeo_reg'
print(x, ...)

## S3 method for class 'bivgeo_reg'
print(x, ...)

## S3 method for class 'bivgeo_reg'
confint(object, parm, level = 0.95, ...)

Arguments

object

Fitted bivgeo_reg model.

...

Additional S3 arguments.

x

Fitted model or summary object.

parm

Optional coefficient names or positions.

level

Confidence level between zero and one.

Details

Regression model extraction methods

Extraction and summary methods for fitted Basu-Dhar regressions.

For covariate vector \mathbf{x}_{ji}, the coefficient linear predictor is \eta_{ji}=\mathbf{x}_{ji}^T\boldsymbol\beta_j, with \theta_{ji}=\exp(\eta_{ji})/\{1+\exp(\eta_{ji})\}. The reported regression Wald intervals are on the logit-coefficient scale, not on the original \theta scale.

Value

coef() returns logit-scale regression coefficients; vcov() returns their covariance matrix; logLik() returns the log-likelihood; nobs() returns the sample size; and confint() returns Wald interval limits on the logit scale.

References

Achcar, J. A., Davarzani, N. and Souza, R. M. (2016). Basu-Dhar bivariate geometric distribution in the presence of covariates and censored data: a Bayesian approach. Journal of Applied Statistics, 43(9), 1636–1648. doi:10.1080/02664763.2015.1117589.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

data("airquality", package = "datasets")
  d <- airquality[!is.na(airquality$Ozone), ]
  d$X <- as.integer(ceiling(d$Ozone / 15))
  d$Y <- as.integer(pmax(1, ceiling((d$Temp - 50) / 10)))
  d$wind_z <- as.numeric(scale(d$Wind))
  fit <- bivgeo_reg(cbind(X, Y), theta1 = ~ wind_z, data = d)
  coef(fit)              # Logistic coefficient scale
  summary(fit)
  confint(fit)

Paired Diabetic Retinopathy Data with Right Censoring

Description

Paired event or censoring times from 197 patients with diabetic retinopathy, with one laser-treated eye and one untreated control eye per patient. The event is visual loss.

Format

A data frame with 197 rows and seven columns:

id

Patient identifier in the source dataset.

X

Discretized event time or right-censoring threshold for the treated eye.

Y

Discretized event time or right-censoring threshold for the control eye.

status_X

Treated-eye event indicator: 1 for visual loss and 0 for right censoring.

status_Y

Control-eye event indicator: 1 for visual loss and 0 for right censoring.

time_treated

Treated-eye time from the source dataset, in months, with the 6.5-month origin adjustment.

time_control

Control-eye time from the source dataset, in months, with the 6.5-month origin adjustment.

Details

Right-censored diabetic retinopathy data

The event is visual loss, defined as visual acuity below 5/200 at two consecutive visits. In the source dataset, survival times in months are recorded after subtraction of the minimum possible event time of 6.5 months. Censoring can result from death, dropout or the end of the study.

For this package, the source times are discretized into 12-month intervals. An observed event at recorded time t is assigned \lceil t/12\rceil; a right-censored observation is assigned threshold \lfloor t/12\rfloor, representing T > \lfloor t/12\rfloor in the discrete model. A censoring threshold of zero is permitted by fit_bivgeo(). Eye pairs and event indicators are retained from the source data. Discretization discards within-interval timing information.

Source

The diabetic data distributed with the R package survival, with 394 eye-level observations paired by patient into 197 rows. The data are included in BivGeo. https://stat.ethz.ch/R-manual/R-patched/library/survival/html/diabetic.html.

References

Huster, W. J., Brookmeyer, R. and Self, S. G. (1989). Modelling paired survival data with covariates. Biometrics, 45(1), 145–156. doi:10.2307/2532041.

Examples

data("BivGeoDiabetic", package = "BivGeo")
  head(BivGeoDiabetic)
  table(BivGeoDiabetic$status_X, BivGeoDiabetic$status_Y)

Discretized Old Faithful Eruption and Waiting Measurements

Description

Paired eruption durations and subsequent waiting times from datasets::faithful, with two integer-valued transformations for fitting the Basu-Dhar distribution.

Format

A data frame with 272 rows and 5 columns:

X

Positive integer category ceiling(eruptions - 1), bounded below by 1.

Y

Positive integer category ceiling((waiting - 40)/10), bounded below by 1.

period

Indicator of the later half of the recorded sequence (0 or 1).

eruptions

Original eruption duration in minutes.

waiting

Original waiting time until the next eruption, in minutes.

Details

Discretized Old Faithful measurements

The eruptions and waiting columns contain the recorded measurements in minutes. The X and Y columns are derived positive-integer categories; they are not observed event times. These data are used for complete-data estimation examples. The suitability of the geometric model is not established by this transformation.

Source

datasets::faithful, distributed with R; the discretized variables are distributed with BivGeo.

References

Azzalini, A. and Bowman, A. W. (1990). A look at some data on the Old Faithful geyser. Applied Statistics, 39(3), 357–365. doi:10.2307/2347385.

Examples

data("BivGeoFaithful", package = "BivGeo")
  head(BivGeoFaithful)
  summary(BivGeoFaithful[c("X", "Y")])

Bayesian Basu-Dhar Model with Configurable Priors

Description

Fits Basu-Dhar event-time models by random-walk Metropolis sampling of logit-scale coefficients. Proposal scaling is adapted during burn-in.

Usage

bayes_bivgeo(response,
             theta1 = ~1,
             theta2 = ~1,
             theta12 = ~1,
             data = NULL,
             status = NULL,
             iterations = 4000L,
             burnin = 1000L,
             thin = 2L,
             chains = 2L,
             prior_sd = 10,
             proposal_sd = 0.2,
             seed = NULL,
             prior = NULL)

fit_bivgeo_bayesian(response,
                    theta1 = ~1,
                    theta2 = ~1,
                    theta12 = ~1,
                    data = NULL,
                    status = NULL,
                    iterations = 4000L,
                    burnin = 1000L,
                    thin = 2L,
                    chains = 2L,
                    prior_sd = 10,
                    proposal_sd = 0.2,
                    seed = NULL,
                    prior = NULL)

Arguments

response

Two-column matrix of discrete event times or censoring thresholds, or a cbind() expression evaluated in data.

theta1, theta2, theta12

One-sided model formulas specifying covariates for each Basu-Dhar parameter (default ~1).

data

Optional data frame in which to evaluate the response expression and the regression formulas.

status

Optional two-column matrix of event indicators: 1 for an observed event at the recorded time and 0 for right censoring at a threshold t, representing a discrete event time greater than t. With status = NULL, all pairs are observed.

iterations

Iterations per chain, including burn-in.

burnin

Number of initial iterations discarded per chain.

thin

Keep every thin-th iteration following burn-in.

chains

Number of independent chains.

prior_sd

Standard deviation of the default normal prior on regression coefficients. A prior_normal() specification in prior replaces this value for the corresponding parameter block.

proposal_sd

Initial proposal standard deviation on logit scale.

seed

Optional random number generator seed.

prior

Optional named list of priors for theta1, theta2 and/or theta12, constructed using prior_normal(), prior_beta(), prior_uniform(), or prior_custom(). Unspecified blocks retain their default priors. Normal priors act on coefficients on the logit scale; Beta and Uniform priors act on theta itself for intercept-only submodels.

Details

Bayesian regression using the Basu-Dhar distribution

With \boldsymbol\beta denoting all logit-scale regression coefficients and \mathcal{D} the observed bivariate data, the posterior is proportional to

\pi(\boldsymbol\beta\mid\mathcal{D})\propto L(\mathcal{D}\mid\boldsymbol\beta)\pi(\boldsymbol\beta).

The likelihood uses the same four event/censoring contributions as fit_bivgeo(). The Metropolis algorithm samples logit coefficients; priors are configurable by parameter block. When a prior is defined on the original \theta scale, its contribution in the logit parameterization includes the Jacobian

\left|\frac{d\theta}{d\beta}\right|=\theta(1-\theta), \qquad\theta=\frac{e^\beta}{1+e^\beta}.

Burn-in draws are discarded and thinning retains every requested draw. Posterior summaries require assessment of chain convergence. The examples use short chains to limit execution time.

Value

bivgeo_bayes object with an array of MCMC draws, posterior summaries, acceptance fractions, the resolved priors, and regression design.

References

Achcar, J. A., Davarzani, N. and Souza, R. M. (2016). Basu-Dhar bivariate geometric distribution in the presence of covariates and censored data: a Bayesian approach. Journal of Applied Statistics, 43(9), 1636–1648. doi:10.1080/02664763.2015.1117589.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Vehtari, A., Gelman, A., Simpson, D., Carpenter, B. and Buerkner, P.-C. (2021). Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC. Bayesian Analysis, 16(2), 667–718. doi:10.1214/20-BA1221.

See Also

prior_normal, prior_beta, prior_uniform, prior_custom, posterior_bivgeo

Examples

# US state crime rates discretized for an example (not event times).
  data("USArrests", package = "datasets")
  xy <- cbind(X = as.integer(ceiling(USArrests$Murder / 4)),
              Y = as.integer(ceiling(USArrests$Assault / 90)))
  set.seed(2026)
  fit <- bayes_bivgeo(xy,
                      prior = list(theta1 = prior_beta(2, 2),
                                   theta12 = prior_uniform(0.1, 0.95)),
                      iterations = 300, burnin = 150, chains = 2, seed = 2026)
  summary(fit)
  # Check MCMC convergence before interpreting credible intervals.

Basu-Dhar Method-of-Moments Estimation

Description

Estimates the three Basu-Dhar parameters from the sample means of X, Y and min(X,Y). Returns either a named numeric vector or a three-row matrix, depending on the function.

Usage

bivgeo_mom(x,
           y = NULL)

mombivgeo(x,
          y = NULL)

fit_bivgeo_moments(x,
                   y = NULL)

Arguments

x, y

Complete, positive-integer bivariate sample, as a two-column matrix in x or two vectors.

Details

Method-of-moments estimation

Functions and return formats:

bivgeo_mom(x, y)

Estimates the three parameters by the method of moments. Returns a named numeric vector c(theta1, theta2, theta12).

fit_bivgeo_moments(x, y)

Descriptive synonym with the same arguments and return format.

mombivgeo(x, y)

Historical interface: returns a 3-by-1 matrix whose third row is labelled theta3 (historical notation for \theta_{12}).

Unlike the theoretical functions bivgeo_moments() and bivgeo_cor(), the functions here accept an observed two-column sample. They require complete, positive-integer pairs.

For a complete paired sample, let W_i=\min(X_i,Y_i), and write \bar X, \bar Y and \bar W for sample means. Since

E(X)=\frac{1}{1-\theta_1\theta_{12}},\quad E(Y)=\frac{1}{1-\theta_2\theta_{12}},\quad E(W)=\frac{1}{1-\theta_1\theta_2\theta_{12}},

solving the moment equations gives

\widehat\theta_1=\frac{\bar Y(\bar W-1)}{\bar W(\bar Y-1)},\qquad \widehat\theta_2=\frac{\bar X(\bar W-1)}{\bar W(\bar X-1)},

\widehat\theta_{12}=\frac{\bar W(\bar X-1)(\bar Y-1)}{(\bar W-1)\bar X\bar Y}.

The estimates must belong to the admissible parameter space; samples that yield undefined or inadmissible estimates produce an error. mombivgeo() retains the historical three-row matrix return format, using the legacy row label theta3 for \theta_{12}.

Value

bivgeo_mom() and fit_bivgeo_moments() return a numeric vector named theta1, theta2 and theta12. mombivgeo() returns a 3-by-1 numeric matrix with row names theta1, theta2 and theta3. An error is raised if a valid moment estimate cannot be obtained.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

data("BivGeoFaithful", package = "BivGeo")
  xy <- as.matrix(BivGeoFaithful[c("X", "Y")])
  bivgeo_mom(xy)           # Moment estimates, named vector
  fit_bivgeo_moments(xy)   # Descriptive alias
  mombivgeo(xy)            # Historical matrix format

Moments and Dependence of the Basu-Dhar Distribution

Description

Computes marginal means, variances, the cross moment, covariance and Pearson correlation from the Basu-Dhar parameter vector.

Usage

bivgeo_moments(theta)

bivgeo_exy(theta)

bivgeo_cov(theta)

bivgeo_cor(theta)

cfbivgeo(theta)

covbivgeo(theta)

corbivgeo(theta)

bivgeo_cross_moment(theta)

Arguments

theta

Parameter vector, as for dbivgeo.

Details

Analytic moments of the Basu-Dhar distribution

Functions and returned quantities:

bivgeo_moments(theta)

Named list containing mean (two entries), variance (two entries), cross_moment, covariance, and correlation.

bivgeo_exy(theta)

Cross moment E(XY) (one number).

bivgeo_cross_moment(theta)

Alias of bivgeo_exy().

bivgeo_cov(theta)

Population covariance \mathrm{Cov}(X,Y) (one number).

bivgeo_cor(theta)

Population Pearson correlation \rho(X,Y) (one number).

cfbivgeo(theta)

Legacy synonym of bivgeo_exy(); not a sample estimate.

covbivgeo(theta)

Legacy synonym of bivgeo_cov().

corbivgeo(theta)

Legacy synonym of bivgeo_cor().

All functions in this group accept a parameter vector and return theoretical quantities, not estimates from observed data.

Writing g_1=\theta_1\theta_{12} and g_2=\theta_2\theta_{12}, the marginal means and variances are

E(X)=\frac{1}{1-g_1},\qquad E(Y)=\frac{1}{1-g_2},

\mathrm{Var}(X)=\frac{g_1}{(1-g_1)^2},\qquad \mathrm{Var}(Y)=\frac{g_2}{(1-g_2)^2}.

The cross-product moment is

E(XY)=\frac{1-\theta_1\theta_2\theta_{12}^2}{(1-g_1)(1-g_2)(1-\theta_1\theta_2\theta_{12})}.

The covariance and Pearson correlation are

\mathrm{Cov}(X,Y)=\frac{\theta_1\theta_2\theta_{12}(1-\theta_{12})}{(1-g_1)(1-g_2)(1-\theta_1\theta_2\theta_{12})},

\rho(X,Y)=\frac{(1-\theta_{12})\sqrt{\theta_1\theta_2}}{1-\theta_1\theta_2\theta_{12}}.

The correlation is nonnegative and equals zero when \theta_{12}=1 (independence). The historical functions cfbivgeo(), covbivgeo() and corbivgeo() return E(XY), \mathrm{Cov}(X,Y) and \rho(X,Y), respectively.

Value

bivgeo_moments returns a named list of means, variances, the cross-moment E(X * Y), covariance and correlation. The other functions return scalar numeric values.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

Li, J. and Dhar, S. K. (2013). Modeling with bivariate geometric distributions. Communications in Statistics–Theory and Methods, 42(2), 252–266. doi:10.1080/03610926.2011.579704.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

theta <- c(0.45, 0.55, 0.60)
  bivgeo_moments(theta)    # Means, variances, covariance and correlation
  bivgeo_exy(theta)        # Cross-moment E(XY)
  bivgeo_cov(theta)        # Covariance
  bivgeo_cor(theta)        # Correlation
  cfbivgeo(theta)          # Historical alias for E(XY)

Prior Distributions for Basu-Dhar Regression

Description

Construct prior specifications for the prior argument of bayes_bivgeo(). Normal priors act on logit-scale regression coefficients; Beta and Uniform priors act on an original theta parameter.

Usage

prior_normal(mean = 0,
             sd = 2.5,
             intercept_mean = NULL,
             intercept_sd = NULL)

prior_beta(shape1 = 1,
           shape2 = 1)

prior_uniform(min = 0,
              max = 1)

prior_custom(log_density,
             scale = c("coefficient", "theta"))

Arguments

mean, sd

Mean and standard deviation of a normal prior on coefficients. Each can be a scalar, a vector with one value per coefficient, or a named vector with names matching the model-matrix columns for the relevant parameter (for example, (Intercept) and age).

intercept_mean, intercept_sd

Optional values that override mean and sd for the intercept coefficient. Only valid if the model contains an intercept.

shape1, shape2

Positive shape parameters of a Beta prior on theta.

min, max

Bounds of a Uniform prior on theta; must satisfy ⁠0 <= min < max <= 1⁠.

log_density

User-defined function that returns one log-density for its input. For scale = "coefficient", the input is the numeric vector of coefficients for that theta block; for scale = "theta", it is one theta value strictly between zero and one.

scale

Scale of the custom density: "coefficient" or "theta".

Details

Prior distributions for Basu-Dhar models

Prior constructors:

prior_normal()

Normal distribution for logit-scale regression coefficients.

prior_beta()

Beta prior on a constant \theta parameter (intercept-only block).

prior_uniform()

Uniform prior on a specified subinterval of the \theta scale.

prior_custom()

User-supplied log density on the "theta" or "coefficient" scale; the user must supply a proper density.

For a constant Basu-Dhar parameter \theta\in(0,1), the Beta prior has density

\pi(\theta)\propto\theta^{a-1}(1-\theta)^{b-1}, \qquad a>0,\;b>0.

A Uniform prior is constant on a user-specified subinterval of [0,1]. A Normal prior acts on the logit regression coefficient \beta=\log\{\theta/(1-\theta)\}. For theta-scale priors, the Metropolis sampler internally adds the log-Jacobian

\log\left|\frac{d\theta}{d\beta}\right| =\log(\theta)+\log(1-\theta).

Do not include this Jacobian yourself in a custom density specified with scale = "theta". Beta, Uniform and custom theta-scale priors require an intercept-only submodel; covariate submodels use normal or custom coefficient-scale priors. The custom density must be proper for valid posterior inference; this is not checked automatically.

Value

An object of class bivgeo_prior, to place in a named list such as prior = list(theta1 = prior_normal(sd = 2), theta12 = prior_beta(2, 3)).

References

Achcar, J. A., Davarzani, N. and Souza, R. M. (2016). Basu-Dhar bivariate geometric distribution in the presence of covariates and censored data: a Bayesian approach. Journal of Applied Statistics, 43(9), 1636–1648. doi:10.1080/02664763.2015.1117589.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

See Also

bayes_bivgeo

Examples

prior_beta(2, 3)                            # Theta scale
  prior_uniform(0.2, 0.9)                  # Theta scale
  prior_normal(sd = 2, intercept_sd = 5)  # Logit scale
  prior_custom(function(b) sum(stats::dt(b, df = 4, log = TRUE)))

Basu-Dhar Logistic Regression with Censoring

Description

Maximum likelihood regression for three Basu-Dhar parameters, with optional right-censored discrete event times.

Usage

bivgeo_reg(response,
           theta1 = ~1,
           theta2 = ~1,
           theta12 = ~1,
           data = NULL,
           status = NULL,
           start = NULL,
           control = list(maxit = 1000))

fit_bivgeo_regression(response,
                      theta1 = ~1,
                      theta2 = ~1,
                      theta12 = ~1,
                      data = NULL,
                      status = NULL,
                      start = NULL,
                      control = list(maxit = 1000))

Arguments

response

Matrix or expression cbind(x,y) evaluated in data.

theta1, theta2, theta12

One-sided model formulas, for example ~ age.

data

Optional data frame used to evaluate response and model formulas.

status

n-by-2 0/1 matrix or expression evaluated in data. An event is 1 and right censoring at threshold t is 0 (event time > t).

start

Initial regression coefficients on the logit scale, optional.

control

Passed to stats::optim.

Details

Basu-Dhar bivariate geometric regression

The parameters may vary with covariates through three logit models,

\log\left(\frac{\theta_{ji}}{1-\theta_{ji}}\right) =\mathbf{x}_{ji}^{T}\boldsymbol\beta_j,\qquad j\in\{1,2,12\}.

Each \mathbf{x}_{ji} is constructed from the corresponding one-sided R formula theta1, theta2 or theta12. The covariate-specific joint survival is

S_i(x,y)=\theta_{1i}^x\theta_{2i}^y\theta_{12,i}^{\max(x,y)}.

Maximum likelihood uses the joint contribution for both observed event times and right-censored components, as in fit_bivgeo(). Regression coefficients and Wald intervals are on the logit scale; predict(..., type = "parameters") returns the \theta scale.

Value

A bivgeo_reg object supporting coef, vcov, logLik, summary, predict, and residuals.

References

Achcar, J. A., Davarzani, N. and Souza, R. M. (2016). Basu-Dhar bivariate geometric distribution in the presence of covariates and censored data: a Bayesian approach. Journal of Applied Statistics, 43(9), 1636–1648. doi:10.1080/02664763.2015.1117589.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

See Also

fit_bivgeo, bayes_bivgeo

Examples

# Real airquality observations, included with R; no extra packages.
  data("airquality", package = "datasets")
  d <- airquality[!is.na(airquality$Ozone), ]
  d$X <- as.integer(ceiling(d$Ozone / 15))
  d$Y <- as.integer(pmax(1, ceiling((d$Temp - 50) / 10)))
  d$wind_z <- as.numeric(scale(d$Wind))
  fit <- bivgeo_reg(cbind(X, Y), theta1 = ~ wind_z, data = d)
  summary(fit)
  predict(fit, newdata = data.frame(wind_z = c(-1, 0, 1)),
          type = "parameters")
  # Ozone and temperature are transformed to integer categories, not event times.

Summaries and MCMC Trace Plots for Basu-Dhar Bayesian Models

Description

Extracts posterior summaries of logit-scale coefficients and displays Metropolis chain traces and marginal histograms.

Usage

## S3 method for class 'bivgeo_bayes'
coef(object, ...)

## S3 method for class 'bivgeo_bayes'
print(x, ...)

## S3 method for class 'bivgeo_bayes'
summary(object, ...)

## S3 method for class 'summary.bivgeo_bayes'
print(x, ...)

## S3 method for class 'bivgeo_bayes'
plot(x, parm = 1L, ...)

Arguments

object

A fitted bivgeo_bayes object.

...

Graphical or other S3 arguments.

x

Fitted model or summary object.

parm

One parameter name or index for plotting.

Details

Bayesian coefficient summary methods

Methods for posterior coefficient summaries, printing results and inspecting trace plots from the Metropolis sampler. The printed output separates posterior theta-scale parameters from logit coefficients. For models with covariates, the theta-scale table refers to the first fitted observation. Rank-normalized split R-hat and bulk/tail ESS are calculated in base R by mcmc_diagnostics_bivgeo(), without requiring external MCMC diagnostic packages.

Posterior coefficient summaries refer to the logit scale \beta; transformed parameter summaries use \theta=\exp(\beta)/(1+\exp(\beta)) for intercept-only submodels or the full covariate linear predictor in regression. For models with covariates, the automatically printed \theta summary refers to the first fitted covariate profile. Trace plots are on the coefficient (logit) scale. Evaluate R-hat and effective sample sizes before interpreting credible intervals.

Value

Posterior coefficient means or summary output; plotting methods draw chain traces and a histogram.

References

Achcar, J. A., Davarzani, N. and Souza, R. M. (2016). Basu-Dhar bivariate geometric distribution in the presence of covariates and censored data: a Bayesian approach. Journal of Applied Statistics, 43(9), 1636–1648. doi:10.1080/02664763.2015.1117589.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Vehtari, A., Gelman, A., Simpson, D., Carpenter, B. and Buerkner, P.-C. (2021). Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC. Bayesian Analysis, 16(2), 667–718. doi:10.1214/20-BA1221.

Examples

data("USArrests", package = "datasets")
  xy <- cbind(X = as.integer(ceiling(USArrests$Murder / 4)),
              Y = as.integer(ceiling(USArrests$Assault / 90)))
  fit <- bayes_bivgeo(xy, iterations = 240, burnin = 120,
                      chains = 2, seed = 2026)
  coef(fit)  # Logit coefficients
  summary(fit)

Compare Basu-Dhar Model Information Criteria

Description

Compares the likelihood and information criteria of models fitted to the same response and censoring data.

Usage

compare_bivgeo(...)

Arguments

...

Two or more fit_bivgeo or bivgeo_reg objects fitted to exactly the same response times and censoring indicators.

Details

Compare information criteria for fitted Basu-Dhar models

For a fitted model with k free parameters and maximized log-likelihood \widehat\ell, the criteria are

\mathrm{AIC}=-2\widehat\ell+2k,\qquad \mathrm{BIC}=-2\widehat\ell+k\log n.

Compare only fits based on the same response observations and censoring indicators. The procedure does not assign a likelihood-ratio p-value, particularly when an independence restriction lies on the boundary \theta_{12}=1.

Value

Data frame with parameter count, log-likelihood, AIC, and BIC.

References

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

data("airquality", package = "datasets")
  d <- airquality[!is.na(airquality$Ozone), ]
  d$X <- as.integer(ceiling(d$Ozone / 15))
  d$Y <- as.integer(pmax(1, ceiling((d$Temp - 50) / 10)))
  d$wind_z <- as.numeric(scale(d$Wind))
  f0 <- bivgeo_reg(cbind(X, Y), data = d)
  f1 <- bivgeo_reg(cbind(X, Y), theta1 = ~ wind_z, data = d)
  compare_bivgeo(intercept_only = f0, wind = f1)

Basu-Dhar Bivariate Geometric Probabilities and Survival

Description

Evaluates the joint probability mass function, cumulative probability or joint survival of the Basu-Dhar bivariate geometric distribution.

Usage

dbivgeo(x,
        y = NULL,
        theta,
        log = FALSE)

pbivgeo(x,
        y = NULL,
        theta,
        lower.tail = TRUE)

sbivgeo(x,
        y = NULL,
        theta,
        log = FALSE)

dbivgeo1(x,
         y = NULL,
         theta,
         log = FALSE)

dbivgeo2(x,
         y = NULL,
         theta,
         log = FALSE)

Arguments

x, y

Numeric coordinate vectors of equal length, or one scalar and one vector (the scalar is expanded). Alternatively, supply a two-column matrix in x with y = NULL.

theta

Numeric vector c(theta1, theta2, theta12); the first two parameters lie strictly between zero and one; the last belongs to (0,1].

log

Return log-probabilities when TRUE.

lower.tail

In pbivgeo, TRUE returns P(X <= x, Y <= y), FALSE returns the joint survival P(X > x, Y > y) (not the complement of the joint CDF).

Details

Basu-Dhar bivariate geometric distribution

Probability functions:

dbivgeo(x, y, theta)

Joint probability mass P(X=x,Y=y).

dbivgeo1(), dbivgeo2()

Aliases of dbivgeo() with identical return values.

pbivgeo(x, y, theta)

Joint cumulative probability P(X\le x,Y\le y). With lower.tail = FALSE, returns joint survival instead.

sbivgeo(x, y, theta)

Joint survival P(X>x,Y>y); this is not 1-P(X\le x,Y\le y).

For positive integer lifetimes X,Y\in\{1,2,\ldots\}, define the joint survival function at nonnegative integer thresholds as

S(x,y)=P(X>x,Y>y)=\theta_1^x\theta_2^y\theta_{12}^{\max(x,y)},\quad x,y=0,1,\ldots.

The parameter space is 0<\theta_1,\theta_2<1 and 0<\theta_{12}\leq 1. The marginal survival probabilities are

P(X>x)=(\theta_1\theta_{12})^x,\qquad P(Y>y)=(\theta_2\theta_{12})^y.

Thus the joint CDF is

F(x,y)=1-(\theta_1\theta_{12})^x-(\theta_2\theta_{12})^y+S(x,y).

For positive integers x,y, the joint PMF follows from inclusion–exclusion:

p(x,y)=S(x-1,y-1)-S(x,y-1)-S(x-1,y)+S(x,y).

pbivgeo(..., lower.tail = FALSE) and sbivgeo() evaluate S(x,y), not 1-F(x,y). The names dbivgeo1() and dbivgeo2() are retained as aliases of dbivgeo(). The CDF and survival functions floor noninteger thresholds.

Value

dbivgeo, pbivgeo and sbivgeo return numeric vectors.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

Li, J. and Dhar, S. K. (2013). Modeling with bivariate geometric distributions. Communications in Statistics–Theory and Methods, 42(2), 252–266. doi:10.1080/03610926.2011.579704.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

See Also

rbivgeo, fit_bivgeo

Examples

theta <- c(theta1 = 0.45, theta2 = 0.55, theta12 = 0.60)
  dbivgeo(1, 2, theta)               # P(X=1, Y=2)
  dbivgeo(1:4, 2, theta)             # Vectorization
  pbivgeo(2, 3, theta)               # P(X<=2, Y<=3)
  sbivgeo(2, 3, theta)               # P(X>2, Y>3)
  dbivgeo1(1, 2, theta)              # Historical alias

Maximum Likelihood for Basu-Dhar Event Times

Description

Fits a Basu-Dhar model to completely observed or right-censored bivariate discrete event times.

Usage

fit_bivgeo(x,
           y = NULL,
           status = NULL,
           start = NULL,
           control = list(maxit = 1000),
           boundary = TRUE)

Arguments

x, y

Observed integer times; a two-column matrix may be supplied as x.

status

Optional n-by-2 0/1 numeric matrix. One denotes observed event; zero denotes right-censoring at the supplied threshold, meaning X > x or Y > y.

start

Optional length-three initial parameter vector.

control

List passed to stats::optim.

boundary

Whether to compare the independence model with theta12 = 1.

Details

Maximum-likelihood fit of a Basu-Dhar bivariate geometric model

Let p(x,y)=P(X=x,Y=y) and S(x,y)=P(X>x,Y>y). For each observed pair, \delta_{1i},\delta_{2i}\in\{0,1\} indicate whether the corresponding event time was observed (1) or right-censored (0). The individual likelihood contribution is

L_i=p(x_i,y_i)^{\delta_{1i}\delta_{2i}} P(X=x_i,Y>y_i)^{\delta_{1i}(1-\delta_{2i})}

\phantom{L_i=}\times P(X>x_i,Y=y_i)^{(1-\delta_{1i})\delta_{2i}} S(x_i,y_i)^{(1-\delta_{1i})(1-\delta_{2i})}.

The total log-likelihood is \ell(\theta)=\sum_{i=1}^n\log L_i. Right censoring at time t means the latent lifetime is greater than t, according to the discrete-time convention. Optimization uses logit-transformed parameters and optionally compares the \theta_{12}=1 independence boundary. Standard errors and Wald intervals derive from the observed Hessian and may be unreliable near parameter boundaries; at a selected boundary some standard errors are unavailable.

Value

Object of class bivgeo_fit with coefficients, logLik, vcov, convergence and fitted values. Standard errors at boundaries are NA.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

Achcar, J. A., Davarzani, N. and Souza, R. M. (2016). Basu-Dhar bivariate geometric distribution in the presence of covariates and censored data: a Bayesian approach. Journal of Applied Statistics, 43(9), 1636–1648. doi:10.1080/02664763.2015.1117589.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

See Also

bivgeo_reg, bayes_bivgeo

Examples

# Discretized eruption and waiting measurements, without censoring.
  data("BivGeoFaithful", package = "BivGeo")
  fit <- fit_bivgeo(as.matrix(BivGeoFaithful[c("X", "Y")]))
  coef(fit)
  confint(fit)

  # Right-censored retinopathy data paired by patient.
  # X is the treated eye, Y the untreated eye; times binned into 12-month
  # intervals. Event indicators are from the original survival study.
  data("BivGeoDiabetic", package = "BivGeo")
  times <- as.matrix(BivGeoDiabetic[c("X", "Y")])
  status <- as.matrix(BivGeoDiabetic[c("status_X", "status_Y")])
  fit_c <- fit_bivgeo(times, status = status)
  summary(fit_c)

  # Marginal Kaplan-Meier estimates for the two eyes (base R).
  theta_hat <- unname(coef(fit_c))
  old_par <- par(mfrow = c(1, 2))
  for (j in 1:2) {
    time <- times[, j]; event <- status[, j]
    grid <- 0:max(time)
    failures <- tabulate(time[event == 1L] + 1L, nbins = length(grid))
    at_risk <- vapply(grid, function(t) sum(time >= t), integer(1))
    km <- cumprod(1 - failures / pmax(at_risk, 1L))
    plot(grid, km, type = "s", ylim = c(0, 1),
         xlab = "12-month intervals", ylab = "Marginal survival",
         main = c("Treated eye (X)", "Control eye (Y)")[j])
    lines(grid, (theta_hat[j] * theta_hat[3])^grid, type = "s", lty = 2)
    legend("topright", c("Kaplan-Meier", "BivGeo"), lty = 1:2, bty = "n")
  }
  par(old_par)
  # Marginal KM does not assess dependence; censoring at k means T > k.

Fitted Marginal Mean Event Times

Description

Returns expected X and Y for each fitted observation.

Usage

## S3 method for class 'bivgeo_fit'
fitted(object, ...)

## S3 method for class 'bivgeo_reg'
fitted(object, ...)

Arguments

object

A fitted maximum-likelihood Basu-Dhar model.

...

Reserved.

Details

Fitted marginal means from Basu-Dhar models

The fitted values are the two marginal expected lifetimes,

\widehat\mu_{Xi}=\frac{1}{1-\widehat\theta_{1i}\widehat\theta_{12,i}},\qquad \widehat\mu_{Yi}=\frac{1}{1-\widehat\theta_{2i}\widehat\theta_{12,i}}.

In an intercept-only model these means are common to all observations; in a regression they depend on the covariate profiles.

Value

Two-column matrix of marginal fitted expected times.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

data("BivGeoFaithful", package = "BivGeo")
  fit <- fit_bivgeo(as.matrix(BivGeoFaithful[c("X", "Y")]))
  head(fitted(fit))

Joint Cell-Frequency Diagnostics for Basu-Dhar Fits

Description

Compares observed frequencies of (X,Y) with expected frequencies under a fitted Basu-Dhar model, keeping right-tail categories. In regression, expected counts sum observation-specific fitted probabilities.

Usage

joint_gof_bivgeo(object,
                 max_x = 4L,
                 max_y = 4L,
                 nsim = 0L,
                 seed = NULL)

## S3 method for class 'bivgeo_joint_gof'
print(x, ...)

## S3 method for class 'bivgeo_joint_gof'
plot(x, annotate = TRUE, ...)

Arguments

object

A bivgeo_fit or bivgeo_reg object with entirely observed event times (no censoring). Under censoring, use external marginal Kaplan-Meier checks or a censoring-aware validation instead.

max_x, max_y

Positive integers specifying the last separately shown values; the final row/column group all event times exceeding the limit.

nsim

Nonnegative number of simulation replicates for the fixed-parameter reference distribution of the Pearson discrepancy.

seed

Optional seed for reproducible simulations, restored afterward.

x

An object returned by joint_gof_bivgeo.

...

Reserved for future plotting arguments.

annotate

Whether to write counts and residuals inside heatmap cells.

Details

Joint cell-frequency diagnostics for complete BivGeo data

For each joint cell A_{jk} (including aggregated right tails), let O_{jk} be the observed count and E_{jk}=\sum_{i=1}^n P_{\widehat\theta_i}\{(X_i,Y_i)\in A_{jk}\} the expected count. The Pearson discrepancy is

T=\sum_{j,k:E_{jk}>0}\frac{(O_{jk}-E_{jk})^2}{E_{jk}}.

The right-tail categories ensure that the counts cover the full bivariate support. The reference distribution simulates at the fitted parameters without refitting; it does not supply a calibrated model-fit p-value. Small expected counts make naive asymptotic chi-squared calibration unreliable. The procedure requires fully observed pairs, because selecting complete cases from censored data changes the joint distribution.

Value

A bivgeo_joint_gof list with observed, expected, pearson_residuals, pearson_statistic, observed_tie_fraction, expected_tie_fraction, observed_correlation, and, if requested, simulated_statistics. Entries with expected count below 5 are flagged; no asymptotic chi-squared p-value is reported.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

set.seed(2026)
  sample_xy <- rbivgeo(300, c(0.45, 0.55, 0.60))
  fit <- fit_bivgeo(sample_xy)
  g <- joint_gof_bivgeo(fit, max_x = 3, max_y = 3, nsim = 49, seed = 2026)
  print(g)  # Joint frequencies, ties and correlation; no calibrated p-value.

MCMC convergence diagnostics for BivGeo Bayesian models

Description

Computes rank-normalized split R-hat and bulk and tail effective sample sizes from Metropolis chains. The basic method returns variance-based R-hat and autocorrelation ESS.

Usage

mcmc_diagnostics_bivgeo(object,
                        method = c("auto", "native", "basic", "posterior"))

Arguments

object

A fitted bivgeo_bayes object.

method

"auto" (the default) and "native" use the built-in diagnostics. "basic" returns the variance-based R-hat and autocorrelation ESS. The former option "posterior" is accepted as an alias for "native", without loading any external package.

Details

MCMC convergence diagnostics for BivGeo Bayesian models

For m chains with n retained draws, the effective sample size can be expressed schematically as

n_{\mathrm{eff}}\approx\frac{mn}{1+2\sum_{t\geq 1}\rho_t},

where \rho_t denotes serial autocorrelation at lag t. The native calculation uses rank-normalized split chains, a folded-rank check for \widehat R, and bulk/tail effective sample sizes with a positive and monotone sequence truncation. \widehat R near 1 and large ESS are useful diagnostics, not a proof of convergence. The historical method = "posterior" is an alias for the internal implementation and does not load an external package.

Value

Data frame with one row per logit coefficient. For the native calculation, columns are coefficient, rhat_rank, ess_bulk, ess_tail. For "basic", columns are coefficient, rhat_basic, ess_basic. The method attribute reports the calculation used.

References

Vehtari, A., Gelman, A., Simpson, D., Carpenter, B. and Buerkner, P.-C. (2021). Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC. Bayesian Analysis, 16(2), 667–718. doi:10.1214/20-BA1221.

Examples

data("USArrests", package = "datasets")
  xy <- cbind(X = as.integer(ceiling(USArrests$Murder / 4)),
              Y = as.integer(ceiling(USArrests$Assault / 90)))
  fit <- bayes_bivgeo(xy, iterations = 240, burnin = 120,
                      chains = 2, seed = 2026)
  mcmc_diagnostics_bivgeo(fit, method = "native")
  # Use longer runs for inferential conclusions.

Posterior Parameters on the Probability Scale

Description

Summarizes Bayesian logistic coefficient draws as Basu-Dhar parameter probabilities, either for fitted or new covariate values.

Usage

posterior_bivgeo(object,
                 newdata = NULL,
                 probs = c(0.025, 0.5, 0.975))

Arguments

object

Fitted bivgeo_bayes object.

newdata

Optional data frame used for predictions. When omitted, parameter estimates are produced for the original fitted observations.

probs

Posterior quantile levels between zero and one.

Details

Posterior estimates on the original Basu-Dhar parameter scale

For posterior draw s and covariate profile i,

\theta_{ji}^{(s)}=\frac{\exp(\mathbf{x}_{ji}^T\boldsymbol\beta_j^{(s)})}{1+\exp(\mathbf{x}_{ji}^T\boldsymbol\beta_j^{(s)})},\quad j=1,2,12.

The reported posterior mean is an average of these transformed draws, S^{-1}\sum_s\theta_{ji}^{(s)}; it need not equal the inverse-logit of the posterior mean coefficient. Credible interval endpoints are empirical quantiles of \theta_{ji}^{(s)}.

Value

Numeric array with rows representing observations, columns theta1, theta2, theta12, and third dimension mean plus quantiles.

References

Achcar, J. A., Davarzani, N. and Souza, R. M. (2016). Basu-Dhar bivariate geometric distribution in the presence of covariates and censored data: a Bayesian approach. Journal of Applied Statistics, 43(9), 1636–1648. doi:10.1080/02664763.2015.1117589.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

data("USArrests", package = "datasets")
  xy <- cbind(X = as.integer(ceiling(USArrests$Murder / 4)),
              Y = as.integer(ceiling(USArrests$Assault / 90)))
  fit <- bayes_bivgeo(xy, iterations = 240, burnin = 120,
                      chains = 2, seed = 2026)
  posterior_bivgeo(fit)[1, , ]  # Marginal parameter summaries on theta scale.

Predictions from Fitted Basu-Dhar Models

Description

Predicts the Basu-Dhar parameters, marginal expected event times or joint survival probabilities for specified covariates.

Usage

## S3 method for class 'bivgeo_fit'
predict(object,
        newdata = NULL,
        type = c("parameters", "mean", "survival"),
        times = NULL,
        ...)

## S3 method for class 'bivgeo_reg'
predict(object,
        newdata = NULL,
        type = c("parameters", "mean", "survival"),
        times = NULL,
        ...)

Arguments

object

Fitted bivgeo_fit or bivgeo_reg object.

newdata

Optional data frame for regression predictions.

type

One of "parameters", "mean", or "survival".

times

Required two-column matrix for survival predictions; a single row is recycled for all predictions.

...

Reserved.

Details

Predictions for Basu-Dhar models

For a fitted or predicted parameter triplet (\theta_1,\theta_2,\theta_{12}), marginal mean event times are

\widehat E(X)=\frac{1}{1-\theta_1\theta_{12}},\qquad \widehat E(Y)=\frac{1}{1-\theta_2\theta_{12}}.

At nonnegative integer thresholds x,y, joint survival predictions are

\widehat S(x,y)=\theta_1^x\theta_2^y\theta_{12}^{\max(x,y)}.

Predictions for a regression model are computed at each requested covariate profile. Note that joint survival is not the complement of the joint CDF.

Value

Matrix of parameter predictions, expected event times, or a numeric vector of joint survival probabilities.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

data("airquality", package = "datasets")
  d <- airquality[!is.na(airquality$Ozone), ]
  d$X <- as.integer(ceiling(d$Ozone / 15))
  d$Y <- as.integer(pmax(1, ceiling((d$Temp - 50) / 10)))
  d$wind_z <- as.numeric(scale(d$Wind))
  fit <- bivgeo_reg(cbind(X, Y), theta1 = ~ wind_z, data = d)
  predict(fit, newdata = data.frame(wind_z = c(-1, 0, 1)),
          type = "parameters")
  predict(fit, newdata = data.frame(wind_z = 0), type = "mean")

Generate Basu-Dhar Bivariate Geometric Observations

Description

Generates dependent positive-integer event times using the independent geometric common-shock construction.

Usage

rbivgeo(n,
        theta,
        method = c("shock", "inverse"))

rbivgeo1(n,
         theta)

rbivgeo2(n,
         theta)

Arguments

n

Nonnegative integer sample size.

theta

Parameter vector, as for dbivgeo.

method

Either "shock" (default) or "inverse".

Details

Simulate Basu-Dhar bivariate geometric lifetimes

Simulation interfaces:

rbivgeo(n, theta, method = "shock")

General generator; use method = "shock" for the independent-shock representation or method = "inverse" for conditional inversion.

rbivgeo1(n, theta)

Historical alias for conditional inversion.

rbivgeo2(n, theta)

Historical alias for the shock algorithm.

Each call returns an n\times2 numeric matrix of positive integer-valued observations, with columns X and Y.

Let U_1,U_2,U_{12} be independent geometric lifetimes on \{1,2,\ldots\}, with

P(U_j>t)=\theta_j^t,\quad j\in\{1,2,12\},\quad t=0,1,\ldots.

The common-shock representation is

X=\min(U_1,U_{12}),\qquad Y=\min(U_2,U_{12}).

It yields P(X>x,Y>y)=\theta_1^x\theta_2^y\theta_{12}^{\max(x,y)}. The "shock" method uses geometric variates; "inverse" uses inverse-transform sampling for the independent shock lifetimes. When \theta_{12}=1, take U_{12}=+\infty, giving independent marginals. The historical interfaces rbivgeo1() (inverse) and rbivgeo2() (shock) remain available.

Value

An n-by-2 numeric matrix containing positive integer-valued observations, with columns X and Y.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

Marshall, A. W. and Olkin, I. (1967). A multivariate exponential distribution. Journal of the American Statistical Association, 62(317), 30–44. doi:10.1080/01621459.1967.10482885.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

set.seed(2026)
  theta <- c(0.45, 0.55, 0.60)
  z <- rbivgeo(500, theta, method = "shock")
  head(z)
  colMeans(z)                        # Empirical marginal means
  bivgeo_moments(theta)$mean         # Theoretical means
  head(rbivgeo(5, theta, method = "inverse"))
  head(rbivgeo1(5, theta))           # Historical inverse generator
  head(rbivgeo2(5, theta))           # Historical shock generator

Diagnostic Summaries and Marginal Residual Plots

Description

Computes residual summaries and observed and fitted tie frequencies, and plots marginal residuals against observation index or fitted means.

Usage

## S3 method for class 'bivgeo_fit'
residuals(object,
          type = c("pearson", "response", "quantile"),
          ...,
          seed = NULL)

## S3 method for class 'bivgeo_reg'
residuals(object,
          type = c("pearson", "response", "quantile"),
          ...,
          seed = NULL)

diagnose_bivgeo(object)

## S3 method for class 'bivgeo_diagnostics'
print(x, ...)

## S3 method for class 'bivgeo_fit'
plot(x,
     ...,
     against = c("auto", "index", "fitted"),
     type = c("pearson", "response", "quantile"),
     pch = 16,
     cex = 0.65,
     seed = NULL)

## S3 method for class 'bivgeo_reg'
plot(x,
     ...,
     against = c("auto", "index", "fitted"),
     type = c("pearson", "response", "quantile"),
     pch = 16,
     cex = 0.65,
     seed = NULL)

Arguments

object

Fitted bivgeo_fit or bivgeo_reg object.

type

"pearson" for standardized marginal residuals, "response" for observed minus fitted mean, or "quantile" for randomized marginal quantile residuals (standard normal under a correct model for exactly observed components).

...

Additional plotting parameters.

seed

Optional RNG seed for randomized quantile residuals; the caller's RNG state is restored afterward.

x

Fitted object to plot.

against

Plot residuals against "auto" (observation index when fitted means have at most five distinct values; fitted mean otherwise), "index" or "fitted".

pch, cex

Plotting point symbol and point size.

Details

Diagnostics for Basu-Dhar model fits

For an uncensored marginal observation x_i, the Pearson residual is r_i=(x_i-\widehat\mu_i)/\widehat\sigma_i. For a discrete marginal CDF F_i, a randomized quantile residual is

r_i^Q=\Phi^{-1}\{F_i(x_i-1)+U_i[F_i(x_i)-F_i(x_i-1)]\}, \quad U_i\sim\mathrm{Uniform}(0,1).

For correctly specified continuous-reference marginal diagnostics, r_i^Q has approximately standard normal reference behaviour. Both marginal Pearson and quantile residuals are NA for censored components; they do not test the bivariate dependence structure. Observed tie frequencies are calculated among fully observed pairs, whereas model-expected tie probabilities are unconditional; these quantities should not be compared as a calibrated test under censoring.

Value

diagnose_bivgeo() returns a printed diagnostic list, with the original named components accessible via $; residuals() returns a two-column matrix, and plot() draws marginal residual plots.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

de Oliveira, R. P. and Achcar, J. A. (2018). Basu-Dhar's bivariate geometric distribution in presence of censored data and covariates: some computational aspects. Electronic Journal of Applied Statistical Analysis, 11(1), 108–136. doi:10.1285/i20705948v11n1p108.

Examples

data("BivGeoFaithful", package = "BivGeo")
  fit <- fit_bivgeo(as.matrix(BivGeoFaithful[c("X", "Y")]))
  diagnose_bivgeo(fit)
  head(residuals(fit, type = "quantile", seed = 2026))
  # Joint diagnostics require complete pairs; censored data use other tools.

Parametric Simulation from Fitted Models

Description

Generates complete event-time pairs from fitted Basu-Dhar models, without reapplying a censoring mechanism.

Usage

## S3 method for class 'bivgeo_fit'
simulate(object, nsim = 1, seed = NULL, ...)

## S3 method for class 'bivgeo_reg'
simulate(object, nsim = 1, seed = NULL, ...)

Arguments

object

Fitted model object.

nsim

Number of replicated simulated data sets.

seed

Optional RNG seed.

...

Reserved.

Details

Simulate fitted Basu-Dhar distributions

For each observation and replicate, independent geometric shocks U_1,U_2,U_{12} are generated at the fitted or predicted parameter values, then X=\min(U_1,U_{12}) and Y=\min(U_2,U_{12}). For fitted regressions the probabilities may differ among observations. The output consists of paired matrices, not a product of independent marginal simulations unless \theta_{12}=1.

Value

List of two-column matrices, one per simulated data set.

References

Basu, A. P. and Dhar, S. K. (1995). Bivariate geometric distribution. Journal of Applied Statistical Science, 2(1), 33–44.

Marshall, A. W. and Olkin, I. (1967). A multivariate exponential distribution. Journal of the American Statistical Association, 62(317), 30–44. doi:10.1080/01621459.1967.10482885.

Examples

set.seed(2026)
  xy <- rbivgeo(250, c(0.45, 0.55, 0.60))
  fit <- fit_bivgeo(xy)
  simulated <- simulate(fit, nsim = 2, seed = 2026)
  lapply(simulated, dim)
  lapply(simulated, colMeans)