subsample: Conducts inference using the subsampling procedure

View source: R/subsample.R

subsampleR Documentation

Conducts inference using the subsampling procedure

Description

This function conducts inference and returns the p-value using the subsampling procedure.

Usage

subsample(
  data = NULL,
  lpmodel,
  beta.tgt,
  R = 100,
  Rmulti = 1.25,
  norm = 2,
  phi = 2/3,
  n = NULL,
  replace = FALSE,
  solver = NULL,
  progress = TRUE,
  previous.output = NA
)

Arguments

data

An data frame or a matrix.

lpmodel

The lpmodel object used in the test.

beta.tgt

The value to be tested.

R

The number of bootstrap replications.

Rmulti

The multiplier for the number of bootstrap replications. The product of Rmulti and R refers to the maximum number of bootstrap replications to be conducted if there are errors.

norm

The norm used in the optimization problem. It can be either a 1-norm or a 2-norm. See the details section of estbounds for a list of accepted strings.

phi

The tuning parameter for the subsampling test. The size of each subsample is n^φ where φ \in [0,1].

n

The sample size. This is only required if data is omitted in the input.

replace

A boolean variable to indicate whether the function samples the data with or without replacement.

solver

The name of the linear and quadratic programming solver that is used to obtain the solution to linear and quadratic programs. The solvers supported by this package are cplexAPI, gurobi, limSolve and Rcplex.

progress

The boolean variable for whether the progress bars should be displayed. If it is set as TRUE, the progress bars will be displayed while the code is running.

previous.output

The list of outputs obtained from the previous evaluation of the procedure. This is only used in the fsst test and when previous.out contains the studentized matrix omega.i. The rest of the arguments are ignored.

Details

There are three possible combinations for the parameters phi and replace:

  • If replace is set as FALSE, it refers to the subsampling procedure. In this case, phi has to be inside the interval (0, 1).

  • If replace is set as TRUE and phi is set as 1, then it refers to the bootstrap procedure.

  • If replace is set as TRUE and phi is inside the interval (0, 1), then it refers to the m out of n bootstrap procedure, where m is the size of the subsample and n is the total number of observations.

The following components are required in the lpmodel for the subsampling procedure:

  • A.tgt

  • A.obs

  • A.shp

  • beta.obs

  • beta.shp

Value

Returns a list of output calculated from the function:

pval

The p-value.

T.n

The test statistic T_n.

T.bs

The list of bootstrap estimates of the test statistics from the subsampling procedure.

solver

The solver used.

cv.table

A table of critical values.

call

The matched call.

phi

The φ parameter used.

norm

The norm used.

subsample.size

The size of subsample

test.logical

An indicator variable for whether the computation has been conducted. If test.logical is 1, it refers to the case where beta.tgt is inside the logical bound. If test.logical is 0, it refers to the case where beta.tgt is outside the logical bound.

logical.lb

The logical lower bound.

logical.ub

The logical upper bound.

df.error

A table showing the id of the bootstrap replication(s) with error(s) and the corresponding error message(s).

R.succ

The number of successful bootstrap replications.

Example

  source("./example/dgp_missingdata.R") # Change directory if necessary
  J <- 5
  N <- 1000
  data <- missingdata_draw(J = J, n = N, seed = 1, prob.obs = .5)
  lpm <- missingdata_lpm(J = J, info = "full", data = data)
  subsample(data = data,
           lpmodel = lpm,
           beta.tgt = .2,
           R = 100,
           phi = 2/3,
           solver = "gurobi")

More examples

More examples can be found in the subsample_example.R file under the example subdirectory of the installation directory for the lpinfer package.


conroylau/lpinfer documentation built on Oct. 23, 2022, 9:21 a.m.