Skip to contents

A quoted formula, will be used to fit the alternative model.

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))

# A formula with environment equals to `test`
test$alt_formula
#> y ~ x + I(x^2)

# Use alternative formula in `fit`
test$fit(test$gen(10), test$alt_formula)
#> 
#> Call:
#> stats::lm(formula = y ~ x + I(x^2), data = test$gen(10))
#> 
#> Coefficients:
#> (Intercept)            x       I(x^2)  
#>      0.4546       3.1471      -0.9350  
#> 

# F-test also needs to use the alternative model
test$test(test$gen(1000))
#> $name
#> [1] "F-test"
#> 
#> $statistic
#> [1] 1.744172
#> 
#> $p_value
#> [1] 0.1869141
#>