Description Usage Arguments Details Value Author(s) Examples
This function simulates linear regressions and stores the parameters and influence measures of all simulations that resulted in LOO significance reversal, developed for research purposes.
1 |
x |
the x values to be supplied to |
slope |
the slope β_1 to be supplied to |
intercept |
the intercept β_0 to be supplied to |
error |
the \varepsilon value to be supplied to |
nrev |
the number of desired significance reversals. |
... |
other parameters to |
Loops over an undefined number of EXACT regressions (lmExact
) with incrementing random seeds, stores all models and in case of significance reversal, parameters and influence measures (lmInfl
). The simulation terminates when nrev
reversals are counted.
A list with the following two items:
models |
the linear models of all reversals. |
mat |
the stored matrix with the resulting parameters and influence measures for all |
Andrej-Nikolai Spiess
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Example with slight slope, intercept = 0.5 and 10 reversals.
res <- simInfl(x = 1:10, intercept = 0.5, slope = 0.02, error = 0.05, nrev = 10)
## Plot Cook's D versus delta-P values
## and insert common cut-off.
plot(res$mat[, "cook.d"], res$mat[, "dP"], pch = 16, cex = 0.5,
xlab = "Cook's D", ylab = "delta-P")
thresh <- qf(0.5, 2, 8) # threshold value for Qf(0.5, npar, df)
abline(v = thresh, col = "darkred", lwd = 2)
## Plot dfbeta slope versus delta-P values
## and insert common cut-off.
plot(res$mat[, "dfb.Slope"], res$mat[, "dP"], pch = 16, cex = 0.5,
xlab = "dfbeta Slope", ylab = "delta-P")
thresh <- 2/sqrt(10) # 2/sqrt(N)
abline(v = thresh, col = "darkred", lwd = 2)
## Plot dffits versus delta-P values
## and insert common cut-off.
plot(abs(res$mat[, "dffit"]), res$mat[, "dP"], pch = 16, cex = 0.5,
xlab = "dffits", ylab = "delta-P")
thresh <- 2 * sqrt(2/10) # 2 * sqrt(nPar/N)
abline(v = thresh, col = "darkred", lwd = 2)
## More illustrative with more reverser samples!
## Example with slight slope, intercept = 0.5 and 10 reversals.
res <- simInfl(x = 1:10, intercept = 0.5, slope = 0.02, error = 0.05, nrev = 200)
plot(res$mat[, "cook.d"], res$mat[, "dP"], pch = 16, cex = 0.5,
xlab = "Cook's D", ylab = "delta-P")
thresh <- qf(0.5, 2, 8) # threshold value for Qf(0.5, npar, df)
abline(v = thresh, col = "darkred", lwd = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.