Skip to contents

The Chapter 5 case study. Each replication generates data from the change-point model \(y = \beta_1 t\, 1(t \le \theta) + \beta_2 t\, 1(t > \theta) + \epsilon\) on the grid \(t = 1/n, \ldots, 1\) with normal errors of standard deviation sigma, estimates the change point \(\theta\) by least squares (a 100-point random search for a starting value followed by Brent's method), and forms a residual-bootstrap percentile interval from B resamples.

Usage

regression_worker(n, set_up, ...)

Arguments

n

Sample size for each replication.

set_up

One element of make_set_up().

...

The model parameters, in order: theta, sigma, beta_1, beta_2, and B (the number of bootstrap resamples).

Value

A 3 x set_up$n_reps matrix with rows theta_hat, lower, and upper.

See also

Other workers: iqr_worker(), pi_worker()

Examples

# \donttest{
out <- sim_template(regression_worker, 1234, 200, 4, 2, .5, .25, 1, 1.5, 50)
bind_results(out)
#>                [,1]      [,2]      [,3]      [,4]
#> theta_hat 0.5014888 0.4972498 0.4364770 0.4919357
#> lower     0.3819660 0.3819660 0.2617897 0.4719262
#> upper     0.6168304 0.6176498 0.6113548 0.6672264
# }