simInfl: Simulates significance reversals and calculates their...

Description Usage Arguments Details Value Author(s) Examples

View source: R/simInfl.R

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

1
simInfl(x = 1:10, slope = 0.02, intercept = 1, error = 0.05, nrev = 1000, ...) 

Arguments

x

the x values to be supplied to lmExact.

slope

the slope β_1 to be supplied to lmExact.

intercept

the intercept β_0 to be supplied to lmExact.

error

the \varepsilon value to be supplied to lmExact.

nrev

the number of desired significance reversals.

...

other parameters to lmExact and lmInfl.

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 nrev reversals.

Author(s)

Andrej-Nikolai Spiess

Examples

 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)  

reverseR documentation built on May 2, 2019, 10:59 a.m.