simInfl {reverseR} | R Documentation |
Simulates significance reversals and calculates their influence parameters
Description
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.
Usage
simInfl(x = 1:10, slope = 0.02, intercept = 1, error = 0.05, nrev = 1000, ...)
Arguments
x |
the |
slope |
the slope |
intercept |
the intercept |
error |
the |
nrev |
the number of desired significance reversals. |
... |
Details
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.
Value
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 |
Author(s)
Andrej-Nikolai Spiess
Examples
## 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)