Skip to contents

This function will be called after an instance is built. User input will be stored in the environment. The response variable of this model is y. The formula of y is defined in SIMPLE_CUBIC_MODEL$formula, the null formula is defined in SIMPLE_CUBIC_MODEL$null_formula, the alternative is defined in SIMPLE_CUBIC_MODEL$alt_formula.

Arguments

a

Numeric. Default is a = 1.

b

Numeric. Default is b = 1.

sigma

Positive numeric. Default is sigma = 1.

x

Random variable or closed form expression. Default is x = rand_uniform(-1, 1, env = new.env(parent = parent.env(self))).

e

Random variable or closed form expression. Default is e = rand_normal(0, sigma, env = new.env(parent = parent.env(self))).

Value

Return the object itself.

Examples


# Instantiate
x <- rand_uniform()
e <- rand_normal()

test <- simple_cubic_model(a = 200, b = 200, x = x, e = e)

test
#> 
#> ── <SIMPLE_CUBIC_MODEL object>
#> y = 1 + x + a * x^2 + b * x^3 + e
#>  - x: <RAND_UNIFORM object>
#>    [a: 0, b: 1]
#>  - e: <RAND_NORMAL object>
#>    [mu: 0, sigma: 1]
#> Parameters:
#>  - a: 200
#>  - b: 200
#>  - sigma: 1 

# Generate data
test$gen(10)
#>            y         x          e    .resid    .fitted
#> 1  168.53846 0.7030087 -1.4971662 -23.70854 192.246999
#> 2  303.31711 0.8922242  0.1585662  19.41738 283.899738
#> 3  159.53752 0.6851842 -0.3788172 -24.07557 183.613093
#> 4  166.67202 0.6975997 -0.2513820 -22.95495 189.626974
#> 5   75.89404 0.4976895  0.2023785 -16.89983  92.793873
#> 6   26.59478 0.3092583  0.2418459  25.07372   1.521064
#> 7  372.68988 0.9691593  0.8063879  51.52411 321.165770
#> 8   19.91782 0.2682683  0.3946286  38.25161 -18.333790
#> 9  140.99932 0.6501972 -0.1771570 -25.66668 166.666004
#> 10  84.94296 0.5247555 -0.5556692 -20.96124 105.904197

# Generate lineup
test$gen_lineup(10, k = 3)
#>              y           x          e      .resid    .fitted test_name
#> 1    8.2979016 0.161186423  1.1029437  -0.1810592   8.478961    F-test
#> 2  256.4668756 0.832564333  0.5810179  46.9087077 209.558168    F-test
#> 3   84.6665356 0.523206639 -0.2507683 -32.2383011 116.904837    F-test
#> 4    4.2535880 0.099319639  0.9854447  14.3038692 -10.050281    F-test
#> 5   13.0242841 0.218025394  0.2264736 -12.4780776  25.502362    F-test
#> 6    1.4488015 0.005001875  0.4387708  39.7474671 -38.298666    F-test
#> 7   35.7144364 0.361099309 -1.1421487 -32.6388873  68.353324    F-test
#> 8   10.0986066 0.194766170 -0.1605784  -8.4375648  18.536171    F-test
#> 9  114.0838802 0.594807324 -0.3581386 -24.2655241 138.349404    F-test
#> 10 189.1403245 0.733409113  0.9306020   9.2793701 179.860954    F-test
#> 11  -8.0670428 0.161186423  1.1029437 -16.5460036   8.478961    F-test
#> 12 207.5567827 0.832564333  0.5810179  -2.0013852 209.558168    F-test
#> 13 104.0802194 0.523206639 -0.2507683 -12.8246173 116.904837    F-test
#> 14  -1.8858816 0.099319639  0.9854447   8.1643997 -10.050281    F-test
#> 15   0.2215766 0.218025394  0.2264736 -25.2807851  25.502362    F-test
#> 16  13.7648935 0.005001875  0.4387708  52.0635591 -38.298666    F-test
#> 17  42.2702022 0.361099309 -1.1421487 -26.0831215  68.353324    F-test
#> 18   5.8680439 0.194766170 -0.1605784 -12.6681274  18.536171    F-test
#> 19 127.0132471 0.594807324 -0.3581386 -11.3361571 138.349404    F-test
#> 20 226.3731930 0.733409113  0.9306020  46.5122386 179.860954    F-test
#> 21  -4.2545274 0.161186423  1.1029437 -12.7334883   8.478961    F-test
#> 22 205.0324757 0.832564333  0.5810179  -4.5256922 209.558168    F-test
#> 23  79.6824498 0.523206639 -0.2507683 -37.2223869 116.904837    F-test
#> 24 -32.5116747 0.099319639  0.9854447 -22.4613934 -10.050281    F-test
#> 25  77.6324531 0.218025394  0.2264736  52.1300913  25.502362    F-test
#> 26 -16.0025462 0.005001875  0.4387708  22.2961194 -38.298666    F-test
#> 27  50.8838919 0.361099309 -1.1421487 -17.4694318  68.353324    F-test
#> 28  -2.7992422 0.194766170 -0.1605784 -21.3354135  18.536171    F-test
#> 29 165.7153670 0.594807324 -0.3581386  27.3659627 138.349404    F-test
#> 30 193.8165869 0.733409113  0.9306020  13.9556325 179.860954    F-test
#>       statistic      p_value k  null
#> 1  8174.6834385 4.937111e-11 1 FALSE
#> 2  8174.6834385 4.937111e-11 1 FALSE
#> 3  8174.6834385 4.937111e-11 1 FALSE
#> 4  8174.6834385 4.937111e-11 1 FALSE
#> 5  8174.6834385 4.937111e-11 1 FALSE
#> 6  8174.6834385 4.937111e-11 1 FALSE
#> 7  8174.6834385 4.937111e-11 1 FALSE
#> 8  8174.6834385 4.937111e-11 1 FALSE
#> 9  8174.6834385 4.937111e-11 1 FALSE
#> 10 8174.6834385 4.937111e-11 1 FALSE
#> 11   11.4741510 8.903986e-03 2  TRUE
#> 12   11.4741510 8.903986e-03 2  TRUE
#> 13   11.4741510 8.903986e-03 2  TRUE
#> 14   11.4741510 8.903986e-03 2  TRUE
#> 15   11.4741510 8.903986e-03 2  TRUE
#> 16   11.4741510 8.903986e-03 2  TRUE
#> 17   11.4741510 8.903986e-03 2  TRUE
#> 18   11.4741510 8.903986e-03 2  TRUE
#> 19   11.4741510 8.903986e-03 2  TRUE
#> 20   11.4741510 8.903986e-03 2  TRUE
#> 21    0.1754956 8.431973e-01 3  TRUE
#> 22    0.1754956 8.431973e-01 3  TRUE
#> 23    0.1754956 8.431973e-01 3  TRUE
#> 24    0.1754956 8.431973e-01 3  TRUE
#> 25    0.1754956 8.431973e-01 3  TRUE
#> 26    0.1754956 8.431973e-01 3  TRUE
#> 27    0.1754956 8.431973e-01 3  TRUE
#> 28    0.1754956 8.431973e-01 3  TRUE
#> 29    0.1754956 8.431973e-01 3  TRUE
#> 30    0.1754956 8.431973e-01 3  TRUE

# Plot the lineup
test$plot_lineup(test$gen_lineup(100))