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 QUARTIC_MODEL$formula, the null formula is defined in QUARTIC_MODEL$null_formula, the alternative is defined in QUARTIC_MODEL$alt_formula.

Arguments

a

Numeric. Default is a = 1.

b

Numeric. Default is b = 1.

c

Numeric. Default is c = 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 <- quartic_model(a = 200, b = 200, c = 20, x = x, e = e)

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

# Generate data
test$gen(10)
#>            y         x            e     .resid    .fitted
#> 1  266.48809 0.8326320  0.938881482  -1.800431 268.288523
#> 2   26.51895 0.3091217  0.008264311  30.234716  -3.715769
#> 3  205.34567 0.7511824 -0.403337227 -20.623480 225.969154
#> 4  299.17899 0.8731442  0.071562534   9.841233 289.337754
#> 5  218.28410 0.7693290  0.067087294 -17.113629 235.397727
#> 6  328.83247 0.9072684 -0.614122881  21.764498 307.067971
#> 7  345.78039 0.9256728 -0.840134614  29.149906 316.630481
#> 8  111.29668 0.5848244 -1.035898785 -28.236563 139.533243
#> 9  212.67593 0.7591172  1.533917315 -17.415968 230.091894
#> 10 257.80709 0.8236224 -0.632095091  -5.800283 263.607369

# Generate lineup
test$gen_lineup(10, k = 3)
#>              y         x           e      .resid   .fitted test_name
#> 1   54.3271881 0.4284965 -0.23259193  -1.5709352  55.89812    F-test
#> 2   39.1302801 0.3733132 -0.90920584   8.0983724  31.03191    F-test
#> 3  122.5927703 0.6104263 -1.81007892 -15.2849231 137.87769    F-test
#> 4   21.1949939 0.2725567  0.90514030  35.5650532 -14.37006    F-test
#> 5  110.0813949 0.5798953 -0.01716754 -14.0387046 124.12010    F-test
#> 6  103.9378940 0.5716289 -2.47815205 -16.4572710 120.39516    F-test
#> 7  295.0216335 0.8686505 -0.23346133  40.7852952 254.23634    F-test
#> 8  121.5066421 0.6049306 -0.23855210 -13.8946337 135.40128    F-test
#> 9   90.9914387 0.5342331  0.25253545 -12.5527408 103.54418    F-test
#> 10  84.1062062 0.5147296  0.92304862 -10.6495125  94.75572    F-test
#> 11  61.5382280 0.4284965 -0.23259193   5.6401047  55.89812    F-test
#> 12   2.4728132 0.3733132 -0.90920584 -28.5590945  31.03191    F-test
#> 13 151.5442297 0.6104263 -1.81007892  13.6665363 137.87769    F-test
#> 14  -0.6372846 0.2725567  0.90514030  13.7327747 -14.37006    F-test
#> 15 122.1688830 0.5798953 -0.01716754  -1.9512165 124.12010    F-test
#> 16  76.1001927 0.5716289 -2.47815205 -44.2949723 120.39516    F-test
#> 17 254.3409886 0.8686505 -0.23346133   0.1046503 254.23634    F-test
#> 18 147.1006095 0.6049306 -0.23855210  11.6993337 135.40128    F-test
#> 19 104.6043717 0.5342331  0.25253545   1.0601922 103.54418    F-test
#> 20 123.6574099 0.5147296  0.92304862  28.9016913  94.75572    F-test
#> 21  10.5135488 0.4284965 -0.23259193 -45.3845745  55.89812    F-test
#> 22  31.4304791 0.3733132 -0.90920584   0.3985714  31.03191    F-test
#> 23 140.7893153 0.6104263 -1.81007892   2.9116219 137.87769    F-test
#> 24  -3.7014761 0.2725567  0.90514030  10.6685833 -14.37006    F-test
#> 25 153.2225809 0.5798953 -0.01716754  29.1024814 124.12010    F-test
#> 26 113.2009035 0.5716289 -2.47815205  -7.1942615 120.39516    F-test
#> 27 238.3662294 0.8686505 -0.23346133 -15.8701090 254.23634    F-test
#> 28 162.9525012 0.6049306 -0.23855210  27.5512254 135.40128    F-test
#> 29 108.2715220 0.5342331  0.25253545   4.7273425 103.54418    F-test
#> 30  87.8448377 0.5147296  0.92304862  -6.9108810  94.75572    F-test
#>       statistic      p_value k  null
#> 1  1124.3940219 1.716002e-07 3 FALSE
#> 2  1124.3940219 1.716002e-07 3 FALSE
#> 3  1124.3940219 1.716002e-07 3 FALSE
#> 4  1124.3940219 1.716002e-07 3 FALSE
#> 5  1124.3940219 1.716002e-07 3 FALSE
#> 6  1124.3940219 1.716002e-07 3 FALSE
#> 7  1124.3940219 1.716002e-07 3 FALSE
#> 8  1124.3940219 1.716002e-07 3 FALSE
#> 9  1124.3940219 1.716002e-07 3 FALSE
#> 10 1124.3940219 1.716002e-07 3 FALSE
#> 11    0.2059589 8.881709e-01 1  TRUE
#> 12    0.2059589 8.881709e-01 1  TRUE
#> 13    0.2059589 8.881709e-01 1  TRUE
#> 14    0.2059589 8.881709e-01 1  TRUE
#> 15    0.2059589 8.881709e-01 1  TRUE
#> 16    0.2059589 8.881709e-01 1  TRUE
#> 17    0.2059589 8.881709e-01 1  TRUE
#> 18    0.2059589 8.881709e-01 1  TRUE
#> 19    0.2059589 8.881709e-01 1  TRUE
#> 20    0.2059589 8.881709e-01 1  TRUE
#> 21    1.8892705 2.492128e-01 2  TRUE
#> 22    1.8892705 2.492128e-01 2  TRUE
#> 23    1.8892705 2.492128e-01 2  TRUE
#> 24    1.8892705 2.492128e-01 2  TRUE
#> 25    1.8892705 2.492128e-01 2  TRUE
#> 26    1.8892705 2.492128e-01 2  TRUE
#> 27    1.8892705 2.492128e-01 2  TRUE
#> 28    1.8892705 2.492128e-01 2  TRUE
#> 29    1.8892705 2.492128e-01 2  TRUE
#> 30    1.8892705 2.492128e-01 2  TRUE

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