Package 'cthreshER'

Title: Continuous Threshold Expectile Regression
Description: Estimation and inference methods for the continuous threshold expectile regression. It can fit the continuous threshold expectile regression and test the existence of change point, for the paper, "Feipeng Zhang and Qunhua Li (2016). A continuous threshold expectile regression, submitted."
Authors: Feipeng Zhang [aut, cre], Qunhua Li [aut]
Maintainer: Feipeng Zhang <[email protected]>
License: GPL (>= 2.0)
Version: 1.1.0
Built: 2025-03-02 03:02:39 UTC
Source: https://github.com/cran/cthreshER

Help Index


Fit the continuous threshold expectile regression

Description

The grid search algorithm for the continuous threshold expectile regression

Usage

cterFit(y, x, z, tau = 0.5, max.iter = 100, tol = 1e-04)

Arguments

y

A vector of response

x

A scalar covariate with threshold

z

A vector of covariates

tau

the expectile level, 0.5 for default

max.iter

the maximum iteration steps, 100 for default

tol

tolerance value, 1e-4 for default

Value

A list with the elements

coef.est

The estimated regression coefficients with intercept.

threshold.est

The estimated threshold.

coef.se

The estimated standard error of the regression coefficients.

threshold.se

The estimated standard error of the threshold.

iter

The iteration steps.

Author(s)

Feipeng Zhang and Qunhua Li

Examples

## simulated data
ptm <- proc.time()
n <- 200
t0 <- 1.5
bet0 <- c(1, 3, -2, 1)
tau <- 0.3
modtype <- 1
errtype <- 1
dat <- cterSimData(n, bet0, t0, tau, modtype, errtype)
y <- dat[, 1]
x <- dat[, 2]
z <- dat[, 3]
fit <- cterFit(y, x, z, tau)

## The example of Baseball pitcher salary
data(data_bbsalaries)
y <- data_bbsalaries$y
x <- data_bbsalaries$x
z <- NULL
tau <- 0.5
fit <- cterFit(y, x, z, tau)
proc.time() - ptm

Simulated data from the continuous threshold expectile regression

Description

The function for simulating data from the continuous threshold expectile regression

Usage

cterSimData(n, bet0, t0, tau = 0.5, modtype = 1, errtype = 1)

Arguments

n

sample size.

bet0

the vecotr of true regression coefficients.

t0

the true location of threshold.

tau

the expectile level, 0.5 for default.

modtype

type of model, 1 = IID for default, 2 = Heteroscedasticity, modtype = 1, Y=beta0+beta1X+beta2(Xt)+gammaZ+e,Y = beta_0 + beta_1 X + beta_2 (X-t)_+ gamma Z + e, modtype = 1, Y=beta0+beta1X+beta2(Xt)+gammaZ+(1+0.2Z)e,Y = beta_0 + beta_1 X + beta_2 (X-t)_+ gamma Z + (1+0.2Z)e,

errtype

type of error, 1 for default, errtype = 1 for N(0, 1), errtype = 2 for t_4, errtype = 3 for 0.9 N(0, 1) + 0.1 t_4.

Value

A matrix with the elements

y

The response variable.

x

The scalar covariate with threshold.

z

A vector of covariates.

Author(s)

Feipeng Zhang and Qunhua Li

Examples

## simulated data
ptm <- proc.time()
n <- 200
t0 <- 1.5
bet0 <- c(1, 3, -2, 1)
tau <- 0.5
modtype <- 1
errtype <- 1
dat <- cterSimData(n, bet0, t0, tau, modtype, errtype)
head(dat)
proc.time() - ptm

test the existence of change point in the continuous threshold expectile regression

Description

This function for calculating the test statistics and p-value by wild bootstrap.

Usage

cterTest(y, x, z, tau = 0.5, NB = 1000)

Arguments

y

A vector of response

x

A scalar covariate with threshold

z

A vector of covariates

tau

the expectile level, 0.5 for default

NB

resampling times, 1000 for default

Value

A list with the elements

Tn

The statistic based on original data.

Tn.NB

The statistics by wild bootstrap.

p.value

The p-value by wild bootstrap.

Author(s)

Feipeng Zhang and Qunhua Li

Examples

## simulated data
ptm <- proc.time()
set.seed(1)
n <- 200
t0 <- 1.5
bet0 <- c(1, 3, 0, 1)
tau <- 0.3
modtype <- 1
errtype <- 1
dat <- cterSimData(n, bet0, t0, tau, modtype, errtype)
y <- dat[, 1]
x <- dat[, 2]
z <- dat[, 3]
fit.test <- cterTest(y, x, z, tau, NB = 30)
fit.test$p.value

## The example of Baseball pitcher salary
data(data_bbsalaries)
y <- data_bbsalaries$y
x <- data_bbsalaries$x
z <- NULL
tau <- 0.5
fit.test <- cterTest(y, x, z, tau, NB = 30)
fit.test$p.value
proc.time() - ptm

Baseball pitcher salary data

Description

Salaries of 176 piters for the 1987 season. The variables are as follows:

Usage

data(data_bbsalaries)

Format

A data frame with 176 observations on the following 2 variables.

y

Log of the base salary in dollars

x

Log of the number of years experience

Source

Hettmansperger, T.P. and McKean J.W. (2011), Robust Nonparametric Statistical Methods, 2nd ed., New York: Chapman-Hall.

References

Hettmansperger, T.P. and McKean J.W. (2011), Robust Nonparametric Statistical Methods, 2nd ed., New York: Chapman-Hall.

Examples

data(data_bbsalaries)
## maybe str(data_bbsalaries) ; plot(data_bbsalaries) ...