Skip to contents

This function test the null model. In this class, the test is either a F-test computed using stats::anova or a RESET test computed using lmtest::resettest.

Arguments

dat

Data frame. A data frame containing all variables needed by the null_formula.

null_formula

Formula. Formula for fitting the null model. Default is null_formula = self$null_formula.

alt_formula

Formula. Formula for fitting the alternative model. Only used in F-test. Default is alt_formula = self$alt_formula.

test

Character. A string representing the test. Either "F" or "RESET".

power

Integer. A vector of integers representing the power of the variables that should be included. Only used in RESET test. Default is 2:3.

power_type

Character. Argument passed to lmtest::resettest. "fitted", "regressor" or "princomp". Only used in RESET test. Default is "fitted".

Value

A list containing the test name, the test statistic and the p-value.

Examples


# Instantiate
mod <- poly_model(shape = 2, sigma = 0.5)

mod
#> 
#> ── <POLY_MODEL object>
#> y = 1 + x + include_z * z + e
#>  - x: <RAND_UNIFORM object>
#>    [a: -1, b: 1]
#>  - z: <CLOSED_FORM object>
#>    EXPR = (raw_z - min(raw_z))/max(raw_z - min(raw_z)) * 2 - 1
#>     - raw_z: <CLOSED_FORM object>
#>       EXPR = hermite(shape)((x - min(x))/max(x - min(x)) * 4 - 2)
#>        - x: <RAND_UNIFORM object>
#>          [a: -1, b: 1]
#>  - e: <RAND_NORMAL object>
#>    [mu: 0, sigma: 0.5]
#> Parameters:
#>  - shape: 2
#>  - include_z: TRUE
#>  - sigma: 0.5 

dat <- mod$gen(100000)

# F-test
mod$test(dat, test = "F")
#> $name
#> [1] "F-test"
#> 
#> $statistic
#> [1] 147619.7
#> 
#> $p_value
#> [1] 0
#> 

# RESET test
mod$test(dat, test = "RESET", power = 2:4)
#> $name
#> [1] "RESET-test"
#> 
#> $statistic
#> [1] 49206.78
#> 
#> $p_value
#> [1] 0
#>