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 CUBIC_MODEL$formula, the null formula is defined in CUBIC_MODEL$null_formula, the alternative is defined in CUBIC_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))).

z

Random variable or closed form expression. Default is z = 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()
z <- rand_uniform()
e <- rand_normal()

test <- cubic_model(a = 200, b = 200, c = 1, x = x, z = z, e = e)

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

# Generate data
test$gen(10)
#>             y          x         z           e     .resid  .fitted
#> 1  142.261912 0.50613202 0.4635440  0.23195582 -66.925513 209.1874
#> 2  290.318543 0.14852255 0.8733548 -2.55009678  -3.880668 294.1992
#> 3  350.623812 0.61950183 0.7900710  0.43012355 -43.509727 394.1335
#> 4  534.580165 0.84462647 0.8526638 -0.69666013  45.140550 489.4396
#> 5    6.660578 0.04072794 0.1335064  1.10036207  87.643775 -80.9832
#> 6  153.678911 0.32775041 0.6198681 -1.27667090 -75.585953 229.2649
#> 7  584.973574 0.79517564 0.9541092 -0.56985678  62.991878 521.9817
#> 8  323.493326 0.21486282 0.9018162  0.82060968  -3.440864 326.9342
#> 9  173.308391 0.65581186 0.3266761  0.58069824 -16.387581 189.6960
#> 10 442.258050 0.42121073 0.9893733 -0.04571533  13.954104 428.3039

# Generate lineup
test$gen_lineup(10, k = 3)
#>            y          x          z          e     .resid   .fitted test_name
#> 1   36.24446 0.23011326 0.30207653 -2.0781075 -11.337853  47.58231    F-test
#> 2  370.38420 0.78813454 0.66124136  0.5204272 -34.782762 405.16696    F-test
#> 3  212.07907 0.01767204 0.77138057 -0.5777430  36.104331 175.97474    F-test
#> 4  357.89635 0.85754417 0.51425928  2.2306483  -8.093742 365.99010    F-test
#> 5  551.61866 0.76828639 0.93756790 -0.4757793  32.982394 518.63627    F-test
#> 6  457.98661 0.69734395 0.87949402 -0.4314085  -9.771313 467.75792    F-test
#> 7   82.45019 0.30156060 0.44287898  0.4315099 -52.301848 134.75204    F-test
#> 8  170.50860 0.70162816 0.07838648 -0.1328384  50.879395 119.62921    F-test
#> 9  431.00046 0.88238663 0.64117824  0.4085165   0.672237 430.32822    F-test
#> 10 138.68686 0.62520825 0.19502245  0.7223721  -4.350839 143.03770    F-test
#> 11  94.22715 0.23011326 0.30207653 -2.0781075  46.644835  47.58231    F-test
#> 12 389.24929 0.78813454 0.66124136  0.5204272 -15.917668 405.16696    F-test
#> 13 145.90705 0.01767204 0.77138057 -0.5777430 -30.067686 175.97474    F-test
#> 14 367.16545 0.85754417 0.51425928  2.2306483   1.175358 365.99010    F-test
#> 15 532.01487 0.76828639 0.93756790 -0.4757793  13.378599 518.63627    F-test
#> 16 435.87184 0.69734395 0.87949402 -0.4314085 -31.886077 467.75792    F-test
#> 17 153.35819 0.30156060 0.44287898  0.4315099  18.606148 134.75204    F-test
#> 18  74.53132 0.70162816 0.07838648 -0.1328384 -45.097885 119.62921    F-test
#> 19 478.29653 0.88238663 0.64117824  0.4085165  47.968312 430.32822    F-test
#> 20 138.23377 0.62520825 0.19502245  0.7223721  -4.803935 143.03770    F-test
#> 21  73.03134 0.23011326 0.30207653 -2.0781075  25.449029  47.58231    F-test
#> 22 459.13155 0.78813454 0.66124136  0.5204272  53.964594 405.16696    F-test
#> 23 153.36176 0.01767204 0.77138057 -0.5777430 -22.612982 175.97474    F-test
#> 24 320.36488 0.85754417 0.51425928  2.2306483 -45.625214 365.99010    F-test
#> 25 489.50304 0.76828639 0.93756790 -0.4757793 -29.133229 518.63627    F-test
#> 26 465.65637 0.69734395 0.87949402 -0.4314085  -2.101550 467.75792    F-test
#> 27 149.51801 0.30156060 0.44287898  0.4315099  14.765970 134.75204    F-test
#> 28  93.16773 0.70162816 0.07838648 -0.1328384 -26.461481 119.62921    F-test
#> 29 466.27908 0.88238663 0.64117824  0.4085165  35.950858 430.32822    F-test
#> 30 138.84171 0.62520825 0.19502245  0.7223721  -4.195994 143.03770    F-test
#>       statistic      p_value k  null
#> 1  2016.6763772 1.791589e-05 3 FALSE
#> 2  2016.6763772 1.791589e-05 3 FALSE
#> 3  2016.6763772 1.791589e-05 3 FALSE
#> 4  2016.6763772 1.791589e-05 3 FALSE
#> 5  2016.6763772 1.791589e-05 3 FALSE
#> 6  2016.6763772 1.791589e-05 3 FALSE
#> 7  2016.6763772 1.791589e-05 3 FALSE
#> 8  2016.6763772 1.791589e-05 3 FALSE
#> 9  2016.6763772 1.791589e-05 3 FALSE
#> 10 2016.6763772 1.791589e-05 3 FALSE
#> 11    4.5409905 1.220741e-01 1  TRUE
#> 12    4.5409905 1.220741e-01 1  TRUE
#> 13    4.5409905 1.220741e-01 1  TRUE
#> 14    4.5409905 1.220741e-01 1  TRUE
#> 15    4.5409905 1.220741e-01 1  TRUE
#> 16    4.5409905 1.220741e-01 1  TRUE
#> 17    4.5409905 1.220741e-01 1  TRUE
#> 18    4.5409905 1.220741e-01 1  TRUE
#> 19    4.5409905 1.220741e-01 1  TRUE
#> 20    4.5409905 1.220741e-01 1  TRUE
#> 21    0.7775372 6.067149e-01 2  TRUE
#> 22    0.7775372 6.067149e-01 2  TRUE
#> 23    0.7775372 6.067149e-01 2  TRUE
#> 24    0.7775372 6.067149e-01 2  TRUE
#> 25    0.7775372 6.067149e-01 2  TRUE
#> 26    0.7775372 6.067149e-01 2  TRUE
#> 27    0.7775372 6.067149e-01 2  TRUE
#> 28    0.7775372 6.067149e-01 2  TRUE
#> 29    0.7775372 6.067149e-01 2  TRUE
#> 30    0.7775372 6.067149e-01 2  TRUE

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