Package 'bifurcatingr'

Title: Bifurcating Autoregressive Models
Description: Estimation of bifurcating autoregressive models of any order, p, BAR(p) as well as several types of bias correction for the least squares estimators of the autoregressive parameters as described in Zhou and Basawa (2005) <doi:10.1016/j.spl.2005.04.024> and Elbayoumi and Mostafa (2020) <doi:10.1002/sta4.342>. Currently, the bias correction methods supported include bootstrap (single, double and fast-double) bias correction and linear-bias-function-based bias correction. Functions for generating and plotting bifurcating autoregressive data from any BAR(p) model are also included. This new version includes calculating several type of bias-corrected and -uncorrected confidence intervals for the least squares estimators of the autoregressive parameters as described in Elbayoumi and Mostafa (2023) <doi:10.6339/23-JDS1092>.
Authors: Tamer Elbayoumi [aut, cre], Sayed Mostafa [aut]
Maintainer: Tamer Elbayoumi <[email protected]>
License: AGPL (>= 3)
Version: 2.1.0
Built: 2024-12-05 07:03:55 UTC
Source: CRAN

Help Index


Standard Normal Bootstrap Confidence Interval Function

Description

This function calculates the standard normal bootstrap CI for the least squares estimator of the bifurcating autoregressive model.

Usage

bfa_boot_ci(a1_ls, a1_ls_star, conf_level = 0.95)

Arguments

a1_ls

A numeric value of the least squares estimator of bifurcating autoregressive model

a1_ls_star

A numeric vector representing B replicates of the least squares estimator

conf_level

A numeric value representing the confidence level. Defaults to 0.95.

Value

A numeric vector representing the lower and upper limits of the confidence interval

Examples

a1_ls <- 0.7
a1_ls_star <- c(rnorm(100,0.7,0.05))
bfa_boot_ci(a1_ls, a1_ls_star, conf_level= 0.95)

Bootstrap of Bias-Correction Least Squares Estimators of BAR(p) Models

Description

This function performs linear-bias-function bias-correction (LBC), single bootstrap, double bootstrap, fast-double bootstrap of the bias-correction least squares estimators of the autoregressive coefficients in a bifurcating autoregressive (BAR) model of any order p as described in Elbayoumi & Mostafa (2020).

Usage

bfa_boot_ls_bc(
  z,
  p,
  method = "boot1",
  burn = 5,
  B,
  boot_est = TRUE,
  boot_data = FALSE
)

Arguments

z

a numeric vector containing the tree data

p

an integer determining the order of bifurcating autoregressive model to be fit to the data

method

method of bias correction. Currently, "boot1", "boot2", "boot2fast" and "LBC" are supported and they implement single bootstrap, double bootstrap, fast-double bootstrap, and linear-bias-function bias-correction, respectively.

burn

number of tree generations to discard before starting the bootstrap sample (replicate)

B

number of bootstrap samples (replicates)

boot_est

a logical that determines whether the bootstrapped least squares estimates of the autoregressive coefficients should be returned. Defaults to TRUE.

boot_data

a logical that determines whether the bootstrap samples should be returned. Defaults to FALSE.

Value

boot_bcest

a matrix containing the bootstrapped bias-correction least squares estimates of the autoregressive coefficients

boot_data

a matrix containing the bootstrap samples used

References

Elbayoumi, T. M. & Mostafa, S. A. (2020). On the estimation bias in bifurcating autoregressive models. Stat, 1-16.

Examples

z <- bfa_tree_gen(31, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
bfa_boot_ls_bc(z, p=1, method="LBC", B=500)
hist(bfa_boot_ls_bc(z, p=1, method="LBC", B=500)$boot_bcest)

Single Bootstrap of Least Squares Estimators of BAR(p) Models

Description

This function performs single bootstrapping of the least squares estimators of the autoregressive coefficients in a bifurcating autoregressive (BAR) model of any order p as described in Elbayoumi and Mostafa (2020).

Usage

bfa_boot1_ls(z, p, burn = 5, B, boot_est = TRUE, boot_data = FALSE)

Arguments

z

a numeric vector containing the tree data

p

an integer determining the order of bifurcating autoregressive model to be fit to the data

burn

number of tree generations to discard before starting the bootstrap sample (replicate)

B

number of bootstrap samples (replicates)

boot_est

a logical that determines whether the bootstrapped least squares estimates of the autoregressive coefficients should be returned. Defaults to TRUE.

boot_data

a logical that determines whether the bootstrap samples should be returned. Defaults to FALSE.

Value

boot_est

a matrix containing the bootstrapped least squares estimates of the autoregressive coefficients

boot_data

a matrix containing the bootstrap samples used

References

Elbayoumi, T. M. & Mostafa, S. A. (2020). On the estimation bias in bifurcating autoregressive models. Stat, 1-16.

Examples

z <- bfa_tree_gen(31, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
bfa_boot1_ls(z, p=1, B=999)

Double Bootstrap of Least Squares Estimators of BAR(p) Models

Description

This function performs double bootstrapping of the least squares estimators of the autoregressive coefficients in a bifurcating autoregressive (BAR) model of any order p as described in Elbayoumi and Mostafa (2020).

Usage

bfa_boot2_ls(z, p, burn = 5, B1, B2)

Arguments

z

a numeric vector containing the tree data

p

an integer determining the order of bifurcating autoregressive model to be fit to the data

burn

number of tree generations to discard before starting the bootstrap sample (replicate)

B1

number of bootstrap samples (replicates) used in first round of bootstrapping

B2

number of bootstrap samples (replicates) used in second round of bootstrapping

Value

boot_est

a matrix containing the first-stage bootstrapped least squares estimates of the autoregressive coefficients

boot2

a matrix containing the second-stage bootstrapped least squares estimates of the autoregressive coefficients

References

Elbayoumi, T. M. & Mostafa, S. A. (2020). On the estimation bias in bifurcating autoregressive models. Stat, 1-16.

Examples

z <- bfa_tree_gen(31, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
bfa_boot2_ls(z, p=1, B1=99, B2=9)

Fast Double Bootstrap of Least Squares Estimators of BAR(p) Models

Description

This function performs fast double bootstrapping of the least squares estimators of the autoregressive coefficients in a bifurcating autoregressive (BAR) model of any order p as described in Elbayoumi and Mostafa (2020).

Usage

bfa_boot2fast_ls(z, p, burn = 5, B)

Arguments

z

a numeric vector containing the tree data

p

an integer determining the order of bifurcating autoregressive model to be fit to the data

burn

number of tree generations to discard before starting the bootstrap sample (replicate)

B

number of bootstrap samples (replicates) used in first round of bootstrapping

Value

boot_est

a matrix containing the first-stage bootstrapped least squares estimates of the autoregressive coefficients

boot2

a matrix containing the second-stage bootstrapped least squares estimates of the autoregressive coefficients

References

Elbayoumi, T. M. & Mostafa, S. A. (2020). On the estimation bias in bifurcating autoregressive models. Stat, 1-16.

Examples

z <- bfa_tree_gen(31, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
bfa_boot2fast_ls(z, p=1, B=499)

Linear Function Bias-Corrected Estimators for BAR(p); p=1,2,...,6

Description

This function performs bias correction on the least squares estimators of the autoregressive coefficients in a BAR(p) model based on the assumption that the bias of the least squares estimator is approximately linear as a function of the parameter as described in Elbayoumi and Mostafa (2020).

Usage

bfa_lbc_ls(z, p)

Arguments

z

a numeric vector containing the tree data

p

an integer determining the order of bifurcating autoregressive model to be fit to the data

Value

coef_lbc

linear-bias-function-based bias-corrected least squares estimates of the autoregressive coefficients

References

Elbayoumi, T. M. & Mostafa, S. A. (2020). On the estimation bias in bifurcating autoregressive models. Stat, 1-16.

Examples

z <- bfa_tree_gen(127, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
bfa_lbc_ls(z, p=1)
z <- bfa_tree_gen(127, 2, 1, 1, 0.5, 0.5, 0, 10, c(0.5, 0.3))
bfa_lbc_ls(z, p=2)

Least Squares Estimation of Bifurcating Autoregressive Models

Description

This function performs Least Squares estimation of bifurcating autoregressive (BFA) models of any order as described in Zhou and Basawa (2005).

Usage

bfa_ls(
  z,
  p,
  x_data = FALSE,
  y_data = FALSE,
  resids = FALSE,
  error_cor = TRUE,
  error_var = FALSE,
  cov_matrix = FALSE,
  conf = FALSE,
  conf_level = 0.95,
  B = 49,
  p_value = FALSE
)

Arguments

z

a numeric vector containing the tree data

p

an integer determining the order of bifurcating autoregressive model to be fit to the data

x_data

a logical that determines whether the x data used in fitting the model should be returned. Defaults to FALSE.

y_data

a logical that determines whether the y data used in fitting the model should be returned. Defaults to FALSE.

resids

a logical that determines whether the model residuals should be returned. Defaults to FALSE.

error_cor

a logical that determines whether the estimated correlation between pairs of model errors (e2t,e2t+1)(e_{2t}, e_{2t+1}) should be returned. Defaults to TRUE.

error_var

a logical that determines whether the estimated variance of the model errors should be returned. Defaults to FALSE.

cov_matrix

a logical that determines whether the estimated variance-covariance matrix of the least squares estimates should be returned. Defaults to FALSE.

conf

a logical that determines whether confidence intervals for model coefficients should be returned. Defaults to FALSE. If TRUE, asymptotic normal confidence intervals for the intercept and the slops are calculated using cov_matrix. In addition, normal bootstrap confidence interval, and percentile confidence interval for the slop are calculated.

conf_level

confidence level to be used in computing the normal confidence intervals for model coefficients when conf=TRUE. Defaults to 0.95.

B

number of bootstrap samples (replicates)

p_value

a logical that determines whether p-values for model coefficients should be returned. Defaults to FALSE. If TRUE, p-values are computed from normal distribution using estimated coefficients and cov_matrix.

Value

coef

a matrix containing the least squares estimates of the autoregressive coefficients

error_cor

the least squares estimate of the correlation between pairs of model errors (e2t,e2t+1)(e_{2t}, e_{2t+1}). Only returned if error_cor=TRUE

x

a matrix containing the x data used in fitting the model. Only returned if x_data=TRUE

y

a vector containing the y data used in fitting the model. Only returned if y_data=TRUE

resids

the model residuals. Only returned if resids=TRUE

error_var

the estimated variance of the model errors. Only returned if error_var=TRUE

cov_matrix

the estimated variance-covariance matrix of the least squares coefficients. Only returned if cov_matrix=TRUE

conf

a matrix of normal confidence intervals for model coefficients. Only returned if conf=TRUE

p_value

a matrix of two-sided p-values for testing the significance of model coefficients. Computed from normal distribution and using the estimated covariance matrix cov_matrix. Only returned if p_value=TRUE

References

Zhou, J. & Basawa, I. V. (2005). Least squares estimation for bifurcating autoregressive processes. Statistics & Probability Letters, 74(1):77-88.

Examples

z <- bfa_tree_gen(127, 1, 1, 1, -0.9, -0.9, 0, 10, c(0.7))
bfa_ls(z, p=1)
bfa_ls(z,p=1,conf=TRUE,cov_matrix = TRUE,conf_level = 0.9,p_value=TRUE)

Bias-Corrected Least Squares Estimators for Bifurcating Autoregressive Models

Description

This function performs bias correction on the least squares estimators of the autoregressive coefficients in a BAR(p) model using single, double and fast-double bootstrapping, and the linear-bias-function approach as described in Elbayoumi and Mostafa (2021).

Usage

bfa_ls_bc(
  z,
  p,
  method = "boot1",
  burn = 5,
  B1 = 999,
  B2 = 499,
  boot_est = TRUE,
  boot_data = FALSE
)

Arguments

z

a numeric vector containing the tree data

p

an integer determining the order of bifurcating autoregressive model to be fit to the data

method

method of bias correction. Currently, "boot1", "boot2", "boot2fast" and "LBC" are supported and they implement single bootstrap, double bootstrap, fast-double bootstrap, and linear-bias-function bias-correction, respectively.

burn

number of tree generations to discard before starting the bootstrap sample (replicate)

B1

number of bootstrap samples (replicates) used in first round of bootstrapping

B2

number of bootstrap samples (replicates) used in second round of bootstrapping

boot_est

a logical that determines whether the bootstrapped least squares estimates of the autoregressive coefficients should be returned. Defaults to TRUE.

boot_data

a logical that determines whether the bootstrap samples should be returned. Defaults to FALSE.

Value

coef_ls_bc

bias-corrected least squares estimates of the autoregressive coefficients

References

Elbayoumi, T. M. & Mostafa, S. A. (2021). On the estimation bias in bifurcating autoregressive models. Stat, e342.

Examples

z <- bfa_tree_gen(63, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
bfa_ls_bc(z, p=2, method="boot1")
z <- bfa_tree_gen(63, 2, 1, 1, 0.5, 0.5, 0, 10, c(0.5, 0.3))
bfa_ls_bc(z, p=2, method="LBC")

Bias-Corrected Confidence intervals of Least Squares Estimators for Bifurcating Autoregressive Models

Description

This function performs bias correction confidence intervals on the least squares estimators of the autoregressive coefficients in a BAR(p) model using single, fast-double, and the Bias-corrected and accelerated bootstrapping as described in Elbayoumi and Mostafa (2023).

Usage

bfa_ls_bc_ci(
  z,
  p,
  method = "BCa",
  conf_int = "standard_normal_bc",
  conf_level = 0.95,
  B = 5,
  burn = 5
)

Arguments

z

a numeric vector containing the tree data

p

an integer determining the order of bifurcating autoregressive model to be fit to the data

method

method of bias correction. Currently, "boot1", "boot2fast", and "BCa" are supported and they implement single bootstrap, fast-double bootstrap, and bias-corrected and accelerated bootstrap, respectively. Defaults to "BCa".

conf_int

type of the confidence interval. Currently, "standard_normal_bc", "percentile", and "percentile_bc" are supported and they implement corrected standard normal bootstrap CI, uncorrected percentile bootstrap CI, and corrected percentile bootstrap CI, respectively. If "boot1" method is selected, the "standard_normal_bc", "percentile", "percentile_bc" confidence intervals can be obtained. If "boot2fast" method is selected, the "standard_normal_bc" and "percentile_bc" confidence intervals can be obtained. No effect for conf_int, the "BCa" method is selected. Defaults to standard_normal_bc".

conf_level

confidence level to be used in computing confidence intervals for model coefficients. Defaults to 0.95.

B

number of bootstrap samples (replicates).

burn

number of tree generations to discard before starting the bootstrap sample (replicate). Defaults to 5.

Value

Bias_corrected_coef

a matrix containing the bias-correction least squares estimates of the autoregressive coefficients

BCa_ci

a matrix containing the lower and upper limits of corrected BCa confidence intervals,if method="BCa"

standard_normal_bc_ci

a matrix containing the lower and upper limits of corrected confidence intervals, if method="boot1" and conf_int="standard_normal_bc" or conf_int="All"

percentile_ci

a matrix containing the lower and upper limits of uncorrected percentile confidence intervals, if method="boot1" and conf_int="percentile" or conf_int="All"

percentile_bc_ci

a matrix containing the lower and upper limits of corrected percentile confidence intervals, if method="boot1" and conf_int="percentile_bc" or conf_int="All"

standard_normal_bc_ci

a matrix containing the lower and upper limits of corrected confidence intervals, if method="boot2fast" and conf_int="standard_normal_bc" or conf_int="All"

percentile_bc_ci

a matrix containing the lower and upper limits of corrected percentile confidence intervals, if method="boot2fast" and conf_int="percentile_bc" or conf_int="All"

References

Elbayoumi, T. M. & Mostafa, S. A. (2023). Impact of Bias Correction of the Least Squares Estimation on Bootstrap Confidence Intervals for Bifurcating Autoregressive Models. Journal of Data Science, 1-20, doi.org/10.6339/23-JDS1092.

Examples

# Generating Non-contaminated normal BAR(1) tree and calculating the bias corrected
# standard normal CI for the autoregressive coefficients of the BAR(1) model
# Note that in this example (B=2) for speeding up the calculations.
# B must be set to 499 or more for calculation accuracy.
z <- bfa_tree_gen(15, 1, 1, 1, -0.9, -0.9, 0, 10, c(-0.5))
bfa_ls_bc_ci(z, p=1, method="boot1", B=2)

Bias Correction Percentile Confidence Interval Function

Description

This function calculates the Bias-Corrected percentile CI for the least squares estimator of the bifurcating autoregressive model.

Usage

bfa_perc_bc_ci(z, a1_ls, a1_ls_star, conf_level = 0.95)

Arguments

z

a numeric vector containing the tree data.

a1_ls

A numeric value of the least squares estimator of bifurcating autoregressive model

a1_ls_star

A numeric vector representing B replicates of the least squares estimator

conf_level

A numeric value representing the confidence level. Defaults to 0.95.

Value

A numeric vector representing the lower and upper limits of the bias corrected percentile confidence interval for the autoregressive coefficients of BAR model.

Examples

# Generating Non-contaminated normal BAR(1) tree and calculating the bias
# corrected percentile CI for the autoregressive coefficients of the BAR(1) model
z <- bfa_tree_gen(31, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
a1_ls <- bfa_ls(z,1)$coef[2]
a1_ls_star <- (rnorm(100,0.7,0.05))
bfa_perc_bc_ci(z, a1_ls, a1_ls_star, conf_level=0.95)

Percentile Bootstrap Confidence Interval Function

Description

This function calculates the percentile bootstrap CI for the least squares estimator of the bifurcating autoregressive model.

Usage

bfa_perc_ci(a1_ls_star, conf_level = 0.95)

Arguments

a1_ls_star

A numeric vector representing B replicates of the least squares estimator.

conf_level

A numeric value representing the confidence level. Defaults to 0.95.

Value

A numeric vector representing the lower and upper limits of the confidence interval.

Examples

a1_ls_star <- c(rnorm(100,0.7,0.05))
bfa_perc_ci(a1_ls_star, conf_level= 0.95)

Scatterplots for Bifurcating Autoregressive Data

Description

Draw scatterplots between observations at time t and the lagged observations from the given bifurcating autoregressive tree data.

Usage

bfa_scatterplot(z, p, ...)

Arguments

z

a numeric vector containing the tree data

p

an integer determining the order of the bifurcating autoregressive model that is believed to best fit the data

...

other graphical parameters that can be passed to plot() or pairs() (see par and pairs)

Value

A single scatterplot when p=1 or a matrix of scatterplots when p>1.

Examples

z <- bfa_tree_gen(63, 1, 1, 2, 0.5, 0.5, 0.2, 10, c(0.7))
bfa_scatterplot(z,1)
z<-bfa_tree_gen(63, 2, 1, 2, 0.5, 0.5, 0.2, 10, c(0.7,0.2))
bfa_scatterplot(z,2)
bfa_scatterplot(z,2,lower.panel=NULL)

Subtree Extractor

Description

This function extracts subtree of size (2p1)(2^p-1) from the end of a given bifurcating autoregressive tree (model) of order p.

Usage

bfa_subtree(n, p)

Arguments

n

subtree size (integer)

p

an integer determining the order of bifurcating autoregressive model

Value

A numeric vector representing a subtree of size (2p1)(2^p-1) from the end of a given bifurcating autoregressive tree.

Examples

bfa_subtree(31, 1)
bfa_subtree(31, 2)

Bifurcating Autoregressive Tree generator

Description

This function generate bifurcating autoregressive (BFA) trees of any size based on a BFA model of any order.

Usage

bfa_tree_gen(n, p, s1, s2, r1, r2, g, intercept, ar_coef, dist = "cnorm", a)

Arguments

n

tree size (integer)

p

an integer determining the order of bifurcating autoregressive model

s1

standard deviation of the errors distribution

s2

standard deviation of the second component of the mixture normal distribution generating contaminated errors. s2 should be greater than s1. s2 is only effective when g>0.

r1

correlation between pairs of errors

r2

is used in combination with r1 to compute the correlation between pairs of errors in the second component of the mixture normal distribution generating the contaminated errors. r2 is only effective when g>0.

g

proportion of contamination when contaminated normal distribution is selected, or a positive value representing the degrees of freedom when skew t-student distribution is selected. Defaults to zero producing non-contaminated multivariate normal errors.

intercept

the intercept in the BAR model generating the tree

ar_coef

a vector of length p giving the autoregressive coefficients in the BAR model generating the tree

dist

determine the distribution of the error. Three distributions are available; Contaminated normal distribution "cnorm", Skew normal distribution "snorm", and Skew t-student distribution "st".

a

an integer which regulates the the slant of the density when skew normal distribution or skew t-student distribution is selected. Defaults to zero producing non-skewed multivariate normal errors, and non-skewed multivariate t-student errors for the tree generation.

Value

A numeric vector representing a bifurcating autoregressive (BAR) tree with n observations.

Examples

# Non-contaminated normal BAR(1) tree:
bfa_tree_gen(127, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
# Non-contaminated normal BAR(2) tree:
bfa_tree_gen(127, 2, 1, 1, 0.5, 0.5, 0, 10, c(0.5, 0.3))
# Contaminated normal BAR(1) tree:
bfa_tree_gen(127, 1, 1, 2, 0.5, 0.5, 0.2, 10, c(0.7))
# BAR(1) tree with error generated from skewed normal distribution with skewness equals to -3:
bfa_tree_gen(127, 1, 1, 2, 0.5, 0.5, 0, 10, c(0.7),dist="snorm",-3)
# BAR(2) tree with error generated from skewed normal distribution with skewness equals to 3:
bfa_tree_gen(127, 2, 1, 2, 0.5, 0.5, 0, 10, c(0.7,0.5),dist="snorm",3)
# BAR(1) tree with error generated from skewed-t distribution with skewness equals
# to -3 and df equals to 10:
bfa_tree_gen(127, 1, 1, 2, 0.5, 0.5, 10, 10, c(0.7),dist="st",-3)
# BAR(2) tree with error generated from skewed-t distribution with skewness equals
# to 3 and df equals to 1:
bfa_tree_gen(127, 2, 1, 2, 0.5, 0.5, 10, 10, c(0.7,0.5),dist="st",3)

Plotting Bifurcating Autoregressive Trees

Description

This function graphs bifurcating autoregressive (BFA) tree data.

Usage

bfa_tree_plot(
  z,
  digits,
  shape = "none",
  vertex.size = 10,
  text.size = 1,
  text.color = "black",
  vertex.color = "gold",
  vertex.asp = 0.25,
  arrow.size = 0.5,
  arrow.width = 0.5,
  arrow.color = "black",
  plot.margin = -0.3
)

Arguments

z

a numeric vector containing the tree data

digits

an integer indicating the number of decimal places to be displayed in vertex labels

shape

the shape of the vertex. Currently “circle”, “square”, “csquare”, “rectangle”, “crectangle”, “vrectangle”, and “none” are supported. Defaults to “none” which does not display the vertices at all.

vertex.size

a numeric scalar or vector defining the size of the vertex or vertices. If a vector is supplied, vertex sizes may differ. Defaults to 10.

text.size

the font size of vertex labels. Defaults to 1.

text.color

the color of vertex labels. If it is a character vector, then it may either contain integer values, named colors or RGB specified colors with three or four bytes. Defaults to "black".

vertex.color

the fill color of the vertex. If you don't want some or all vertices to have any color, supply NA. The default is "gold". See also the options in text.color.

vertex.asp

a parameter that controls the aspect ratio of the plot, The default value is 0.25.

arrow.size

the size of the arrows. The default value is 0.5.

arrow.width

the width of the arrows. The default value is 0.5.

arrow.color

the color of the arrows. The default is "black". See also the options in text.color.

plot.margin

the amount of empty space around the plot, it is a numeric vector of length four. Usually values between 0 and 0.5 are meaningful, but negative values are also possible and in that case it will make the plot zoom in to a part of the graph. If it is shorter than four, recycling will occur. The default value is -0.3.

Details

For more details about the graph options see igraph.plotting.

Value

A binary tree displaying the BFA data.

Examples

z <- bfa_tree_gen(31, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
bfa_tree_plot(z)
bfa_tree_plot(z,shape= "circle")
bfa_tree_plot(z,shape= "circle", text.color="white", vertex.color = "darkgrey",plot.margin = 0)

Bias-Corrected and Accelerated bootstrap Confidence Interval (BCa) Function.

Description

This function calculates the Bias-Corrected and Accelerated bootstrap (BCa) CI for the least squares estimator of the bifurcating autoregressive model.

Usage

boot_bca_ci(z, p, B = 99, J = 2, conf_level = 0.95)

Arguments

z

a numeric vector containing the tree data.

p

an integer determining the order of bifurcating autoregressive model to be fit to the data.

B

number of bootstrap samples (replicates). Defaults to 99.

J

an integer determining the number of vectors of bootstrap replicates. Defaults to 2.

conf_level

A numeric value representing the confidence level. Defaults to 0.95.

Value

coef

a matrix containing the least squares estimates of the autoregressive coefficients

limits

A numeric vector representing the lower and upper limits of the BCa confidence interval for the autoregressive coefficients of BAR model

Examples

# Generating Non-contaminated normal BAR(1) tree and calculating the BCa CI for
# the autoregressive coefficients of the BAR(1) model
z <- bfa_tree_gen(31, 1, 1, 1, 0.5, 0.5, 0, 10, c(0.7))
boot_bca_ci(z,p=1,B=99,J=2,conf_level=0.95)
# Generating Non-contaminated normal BAR(2) tree and calculating the BCa CI for
# the autoregressive coefficients of the BAR(2) model
z <- bfa_tree_gen(127, 2, 1, 1, 0.5, 0.5, 0, 10, c(0.5, 0.3))
boot_bca_ci(z,p=2,B=99,J=2,conf_level=0.95)

Lifetimes (in minutes) of lineage E. coli cells.

Description

A real cell lineage dataset taken from Cowan and Staudte (1986). The values represent the lifetimes in minutes of lineage E. coli cells. It contains 31 observations making which can be described by a bifurcating autoregressive tree with 4 generations.

Usage

ecoli

Format

A data frame with 31 rows and 1 variable:

lifetime

E. coli cells lifetime, in minutes

Source

Cowan, R. and Staudte, R. (1986). The Bifurcating Autoregression Model in Cell Lineage Studies. Biometrics, 42(4):769-783.


Mean Lifetimes (in tenths of hours) of EMT6 (BALB/c mouse mammary tumor) cells.

Description

A real cell lineage dataset taken from Staudte et al. (1984). The values represent the mean lifetimes in tenths of hours obtained from averaging observations from 41 bifurcating trees. The averaging of observations and the tree are made by Elbayoumi and Mostafa (2023).

Usage

emt6

Format

A data frame with 63 rows and 1 variable:

mean.lifetime

EMT6 cells lifetime, in tenths of hours

Source

Elbayoumi, T. and Mostafa, S. (2023). Impact of Bias Correction of the Least Squares Estimation on Bootstrap Confidence Intervals for Bifurcating Autoregressive Models. Journal of Data Science, doi.org/10.6339/23-JDS1092.


Contaminated Normal Generator

Description

This function generates contaminated multivariate normal errors that are used in the generation of the Bifurcating autoregressive tree.

Usage

rcontmnorm(
  n,
  d = 2,
  mu1 = rep(0, d),
  sigma1 = diag(d),
  mu2 = rep(0, d),
  sigma2 = diag(d),
  g
)

Arguments

n

sample size

d

dimension. Defaults to 2 for bivariate normal errors.

mu1

mean vector for first multivariate normal distribution. Defaults to the zero vector.

sigma1

variance-covariance matrix for first multivariate normal distribution. Defaults to the d by d identity matrix, where d is the dimension.

mu2

mean vector for second multivariate normal distribution. Defaults to the zero vector.

sigma2

variance-covariance matrix for second multivariate normal distribution. Defaults to the d by d identity matrix, where d is the dimension.

g

proportion of contamination. Defaults to zero producing non-contaminated multivariate normal data.

Value

An n by d contaminated multivariate normal matrix.

Examples

#Non-contaminated bivariate normal:
rcontmnorm(10, sigma2=2^2*matrix(c(1,0,0,1),nrow=2) , g=0)
#Contaminated bivariate normal with 20% contamination:
rcontmnorm(10, sigma2=2^2*matrix(c(1,0,0,1),nrow=2) , g=0.2)

Multivariate Normal Generator

Description

This function generates multivariate normal errors that are used in the generation of the Bifurcating autoregressive tree.

Usage

rmnorm(n, d = 2, mu = rep(0, d), sigma = diag(d))

Arguments

n

sample size

d

dimension. Defaults to 2 for bivariate normal errors.

mu

mean vector. Defaults to the zero vector.

sigma

variance-covariance matrix. Defaults to the d by d identity matrix, where d is the dimension.

Value

An n by d multivariate normal matrix.

Examples

rmnorm(10)
rmnorm(10, 3)