Skip to contents

This function generates random values from the expression of y, and keeps all the right hand side information in a data frame.

Arguments

n

Integer. Number of observations.

k

Integer. Number of plots in the lineup. Default is k = 20.

pos

Integer. Position of the true data plot. Default is pos = NULL, which means the position is random.

computed

List. Default is NULL. If it is provided, random variables or random closed form expression will use the values from the list, which makes the expression potentially deterministic.

Value

A data frame.

Examples


# Instantiate
x <- rand_uniform()
e <- rand_normal()
test <- vi_model(prm = list(x = x, e = e),
                 prm_type = list(x = "r", e = "r"),
                 formula = y ~ 1 + x + x^2 + e,
                 null_formula = y ~ x,
                 alt_formula = y ~ x + I(x^2))

test$gen_lineup(10, k = 3)
#>            y         x          e     .resid  .fitted test_name statistic
#> 1  2.2337979 0.3184964  0.8138616  0.4524626 1.781335    F-test 13.452795
#> 2  1.2316579 0.4662598 -0.4520001 -0.7315824 1.963240    F-test 13.452795
#> 3  1.6634854 0.6777285 -0.4735591 -0.5600846 2.223570    F-test 13.452795
#> 4  1.3424917 0.3738539 -0.1711289 -0.5069917 1.849483    F-test 13.452795
#> 5  1.3065891 0.7687011 -1.0530134 -1.0289731 2.335562    F-test 13.452795
#> 6  4.7657337 0.9982908  1.7708584  2.1475339 2.618200    F-test 13.452795
#> 7  1.8743713 0.4043063  0.3066015 -0.0126007 1.886972    F-test 13.452795
#> 8  0.4633385 0.6903336 -1.7035555 -1.7757490 2.239087    F-test 13.452795
#> 9  2.8437422 0.2128211  1.5856284  1.1924991 1.651243    F-test 13.452795
#> 10 2.7963563 0.4740823  1.0975199  0.8234861 1.972870    F-test 13.452795
#> 11 2.0154726 0.3184964  0.8138616  0.2341372 1.781335    F-test  1.697958
#> 12 0.6572083 0.4662598 -0.4520001 -1.3060320 1.963240    F-test  1.697958
#> 13 3.7838578 0.6777285 -0.4735591  1.5602878 2.223570    F-test  1.697958
#> 14 0.4117211 0.3738539 -0.1711289 -1.4377624 1.849483    F-test  1.697958
#> 15 3.1871892 0.7687011 -1.0530134  0.8516270 2.335562    F-test  1.697958
#> 16 1.3780200 0.9982908  1.7708584 -1.2401799 2.618200    F-test  1.697958
#> 17 2.4793629 0.4043063  0.3066015  0.5923909 1.886972    F-test  1.697958
#> 18 1.7258043 0.6903336 -1.7035555 -0.5132831 2.239087    F-test  1.697958
#> 19 1.2076225 0.2128211  1.5856284 -0.4436207 1.651243    F-test  1.697958
#> 20 3.6753055 0.4740823  1.0975199  1.7024353 1.972870    F-test  1.697958
#> 21 0.5227955 0.3184964  0.8138616 -1.2585399 1.781335    F-test  1.788007
#> 22 0.2425309 0.4662598 -0.4520001 -1.7207094 1.963240    F-test  1.788007
#> 23 2.9429976 0.6777285 -0.4735591  0.7194276 2.223570    F-test  1.788007
#> 24 1.5241622 0.3738539 -0.1711289 -0.3253212 1.849483    F-test  1.788007
#> 25 2.6112160 0.7687011 -1.0530134  0.2756538 2.335562    F-test  1.788007
#> 26 3.1668421 0.9982908  1.7708584  0.5486422 2.618200    F-test  1.788007
#> 27 1.5513904 0.4043063  0.3066015 -0.3355817 1.886972    F-test  1.788007
#> 28 1.2213615 0.6903336 -1.7035555 -1.0177260 2.239087    F-test  1.788007
#> 29 3.7967325 0.2128211  1.5856284  2.1454894 1.651243    F-test  1.788007
#> 30 2.9415354 0.4740823  1.0975199  0.9686651 1.972870    F-test  1.788007
#>        p_value k  null
#> 1  0.007987396 2 FALSE
#> 2  0.007987396 2 FALSE
#> 3  0.007987396 2 FALSE
#> 4  0.007987396 2 FALSE
#> 5  0.007987396 2 FALSE
#> 6  0.007987396 2 FALSE
#> 7  0.007987396 2 FALSE
#> 8  0.007987396 2 FALSE
#> 9  0.007987396 2 FALSE
#> 10 0.007987396 2 FALSE
#> 11 0.233778614 1  TRUE
#> 12 0.233778614 1  TRUE
#> 13 0.233778614 1  TRUE
#> 14 0.233778614 1  TRUE
#> 15 0.233778614 1  TRUE
#> 16 0.233778614 1  TRUE
#> 17 0.233778614 1  TRUE
#> 18 0.233778614 1  TRUE
#> 19 0.233778614 1  TRUE
#> 20 0.233778614 1  TRUE
#> 21 0.222985393 3  TRUE
#> 22 0.222985393 3  TRUE
#> 23 0.222985393 3  TRUE
#> 24 0.222985393 3  TRUE
#> 25 0.222985393 3  TRUE
#> 26 0.222985393 3  TRUE
#> 27 0.222985393 3  TRUE
#> 28 0.222985393 3  TRUE
#> 29 0.222985393 3  TRUE
#> 30 0.222985393 3  TRUE

test$gen_lineup(10, k = 3, computed = list(e = 1:10))
#>             y  e          x     .resid  .fitted test_name statistic   p_value k
#> 1   2.0946218  1 0.08704496 -3.0056956 5.100317    F-test 1.0685115 0.3356668 2
#> 2   3.1902553  2 0.16351739 -2.3577832 5.548039    F-test 1.0685115 0.3356668 2
#> 3   4.7510404  3 0.50052007 -2.7700389 7.521079    F-test 1.0685115 0.3356668 2
#> 4   5.4434568  4 0.33274054 -1.0953281 6.538785    F-test 1.0685115 0.3356668 2
#> 5   6.9349441  5 0.58855137 -1.1015298 8.036474    F-test 1.0685115 0.3356668 2
#> 6   7.7472215  6 0.49860979  0.2373262 7.509895    F-test 1.0685115 0.3356668 2
#> 7   9.7219859  7 0.90427416 -0.1629420 9.884928    F-test 1.0685115 0.3356668 2
#> 8   9.9284136  8 0.58554760  1.9095258 8.018888    F-test 1.0685115 0.3356668 2
#> 9  11.4795415  9 0.81512034  2.1165801 9.362961    F-test 1.0685115 0.3356668 2
#> 10 11.0386304 10 0.03724331  6.2298855 4.808745    F-test 1.0685115 0.3356668 2
#> 11  6.5805193  1 0.08704496  1.4802020 5.100317    F-test 0.3706724 0.5618672 1
#> 12  0.8308687  2 0.16351739 -4.7171698 5.548039    F-test 0.3706724 0.5618672 1
#> 13  6.3248759  3 0.50052007 -1.1962034 7.521079    F-test 0.3706724 0.5618672 1
#> 14  9.6856315  4 0.33274054  3.1468467 6.538785    F-test 0.3706724 0.5618672 1
#> 15  8.6993940  5 0.58855137  0.6629201 8.036474    F-test 0.3706724 0.5618672 1
#> 16  4.8883880  6 0.49860979 -2.6215073 7.509895    F-test 0.3706724 0.5618672 1
#> 17 13.2123694  7 0.90427416  3.3274415 9.884928    F-test 0.3706724 0.5618672 1
#> 18  9.4345400  8 0.58554760  1.4156522 8.018888    F-test 0.3706724 0.5618672 1
#> 19  5.9292932  9 0.81512034 -3.4336682 9.362961    F-test 0.3706724 0.5618672 1
#> 20  6.7442312 10 0.03724331  1.9354863 4.808745    F-test 0.3706724 0.5618672 1
#> 21  2.9489698  1 0.08704496 -2.1513475 5.100317    F-test 1.2884848 0.2936953 3
#> 22  4.6744424  2 0.16351739 -0.8735961 5.548039    F-test 1.2884848 0.2936953 3
#> 23  9.8049783  3 0.50052007  2.2838990 7.521079    F-test 1.2884848 0.2936953 3
#> 24  3.3966093  4 0.33274054 -3.1421755 6.538785    F-test 1.2884848 0.2936953 3
#> 25  6.7656764  5 0.58855137 -1.2707975 8.036474    F-test 1.2884848 0.2936953 3
#> 26  4.3579368  6 0.49860979 -3.1519585 7.509895    F-test 1.2884848 0.2936953 3
#> 27  9.1282802  7 0.90427416 -0.7566477 9.884928    F-test 1.2884848 0.2936953 3
#> 28  8.4409210  8 0.58554760  0.4220332 8.018888    F-test 1.2884848 0.2936953 3
#> 29 12.7919394  9 0.81512034  3.4289780 9.362961    F-test 1.2884848 0.2936953 3
#> 30 10.0203576 10 0.03724331  5.2116127 4.808745    F-test 1.2884848 0.2936953 3
#>     null
#> 1  FALSE
#> 2  FALSE
#> 3  FALSE
#> 4  FALSE
#> 5  FALSE
#> 6  FALSE
#> 7  FALSE
#> 8  FALSE
#> 9  FALSE
#> 10 FALSE
#> 11  TRUE
#> 12  TRUE
#> 13  TRUE
#> 14  TRUE
#> 15  TRUE
#> 16  TRUE
#> 17  TRUE
#> 18  TRUE
#> 19  TRUE
#> 20  TRUE
#> 21  TRUE
#> 22  TRUE
#> 23  TRUE
#> 24  TRUE
#> 25  TRUE
#> 26  TRUE
#> 27  TRUE
#> 28  TRUE
#> 29  TRUE
#> 30  TRUE