# NOT RUN {
# Load dataset containing data frame with (g, X1*, X2*, Y*, Ytilde*) values
# for 500 pools each of size 1, 2, and 3, and list of Ytilde values where 20
# of the single-specimen pools have replicates. Ytilde values are affected by
# processing error and measurement error; true parameter values are
# beta_0 = 0.25, beta_x1 = 0.5, beta_x2 = 0.25, sigsq = 1.
data(dat_p_linreg_yerrors)
dat <- dat_p_linreg_yerrors$dat
reps <- dat_p_linreg_yerrors$reps
# Fit Ytilde* vs. (X1*, X2*) ignoring errors in Ytilde (leads to loss of
# precision and overestimated sigsq, but no bias).
fit.naive <- p_linreg_yerrors(
g = dat$g,
y = dat$y,
x = dat[, c("x1", "x2")],
errors = "neither"
)
fit.naive$theta.hat
# Account for errors in Ytilde*, without using replicates
fit.corrected.noreps <- p_linreg_yerrors(
g = dat$g,
y = dat$ytilde,
x = dat[, c("x1", "x2")],
errors = "both"
)
fit.corrected.noreps$theta.hat
# Account for errors in Ytilde*, incorporating the 20 replicates
fit.corrected.reps <- p_linreg_yerrors(
g = dat$g,
y = reps,
x = dat[, c("x1", "x2")],
errors = "both"
)
fit.corrected.reps$theta.hat
# In this trial, incorporating replicates resulted in much better estimates
# of sigsq (truly 1), sigsq_p (truly 0.4), and sigsq_m (truly = 0.2) but very
# similar regression coefficient estimates.
fit.corrected.noreps$theta.hat
fit.corrected.reps$theta.hat
# }
Run the code above in your browser using DataLab