“…]) #I put the mean regression estimates from each level of simulated measurement error in a dataset avg_noiseADJ_cons = NA avg_noiseADJ_X1 = NA avg_noiseADJ_X2 = NA lambda = c(-1, 0, .5, 1, 1.5, 2) addi1 = c(avg_noiseADJ_cons, coef(lm.naive) [1], avg.5_cons, avg1_cons, avg1.5_cons, avg2_cons) addi2 = c(avg_noiseADJ_X1, coef(lm.naive) [2], avg.5_X1, avg1_X1, avg1.5_X1, avg2_X1) addi3 = c(avg_noiseADJ_X2, coef(lm.naive) [3], avg.5_X2, avg1_X2, avg1.5_X2, avg2_X2) SIMEX = data.frame(lambda, addi1, addi2, addi3) names(SIMEX) = c("lambda","cons","X1","X2") #I obtain the adjusted SIMEX estimates using a linear extrapolation function SIMEXna = SIMEX[-1,] SIMEX_cons = lm(SIMEXna$cons ~ SIMEXna$lambda) SIMEX [1,2] = coef(SIMEX_cons) [1] + (-1)*coef(SIMEX_cons) [2] SIMEX_X1 = lm(SIMEXna$X1 ~ SIMEXna$lambda) SIMEX [1,3] = coef(SIMEX_X1) [1] + (-1)*coef(SIMEX_X1) [2] SIMEX_X2 = lm(SIMEXna$X2 ~ SIMEXna$lambda) SIMEX [1,4] = coef(SIMEX_X2) [1] + (-1)*coef(SIMEX_X2) [2] #I save the adjusted estimates and the remaining bias results [1,1] = SIMEX [1,2] results [2,1] = SIMEX [1,3] results [3,1] = SIMEX [1,4] bias1 = SIMEX [1,2]-coef(lm.true) [1] bias2 = SIMEX [1,3]-coef(lm.true) [2] bias3 = SIMEX [1,4]-coef(lm.true) [3] results [1,2] = bias1 results[2,2] = bias2 results …”