Skip to contents

Evaluates the mean squared error of the two extrapolants in the evenly spread design of the paper: errors with common variance sigma2, equal weights, and rho comparison respondents per year spread evenly over a window of h years that ends k years before the exposed survey. For each extrapolant the function returns the squared bias plus the variance of the extrapolated mean. For the kernel mean the bias is the slope beta times the distance from the centre of the window to the target, plus a curvature term bounded through M; its variance is that of a simple average of the window. For the local-linear fit the bias is the worst case under the curvature bound M, which grows with the square of k and with the window length, and the variance is that of a regression line predicted k years beyond the window, which grows quickly as the window shortens relative to k. The variance of the exposed mean is the same for both and is left out.

Usage

cdd_risk_ideal(h, k = 0, beta, M, sigma2, rho)

Arguments

h

Vector of window lengths (years).

k

Extrapolation distance (years).

beta

Slope of the cohort trend at the target.

M

Curvature bound.

sigma2

Error variance.

rho

Comparison respondents per year in the window.

Value

A data frame with h, the two mean squared errors (risk0, risk1), and their components. The attribute "h_star" holds the minimizing h for each order over the grid supplied; the attribute "h_foc" holds the solutions of the two first-order conditions (NA when beta = 0 or M = 0, where the optimal window is unbounded).

Details

The attributes of the result give the window that minimizes each expression. A longer window is optimal when the errors are noisy, respondents are few, or the trend is close to flat (kernel mean) or close to linear (local-linear fit). The closed-form expressions and their derivation are in the article that accompanies the package.

Examples

r <- cdd_risk_ideal(h = seq(2, 20, by = 0.5), k = 2, beta = 0.01, M = 0.002, sigma2 = 0.2, rho = 50)
attr(r, "h_star")
#> order0 order1 
#>    2.5   10.0 
attr(r, "h_foc")
#>   order0   order1 
#> 3.308498 9.878342