vartest performs variability tests by either the Breusch-Pagan or Brown-Forsythe methods.
Arguments
- y
vector of outcome values
- x
vector of exposure values
- covar
data.frame
of covariates- covar.var
adjust the second stage (variance component) of the approach by the covariates
- type
type of test, where
1
= Breusch-Pagan variance test, and2
= Brown-Forsythe variance test (default:1
)- x.sq
include x-squared in the variance part of the model
Value
vartest
returns a list
of results:
- coef
model coefficients from variance part of the model
- test
data.frame
of test results
F
: the test statisticDF
: the degrees of freedomP
: the p-value
Author
James Staley jrstaley95@gmail.com
Examples
x <- rbinom(1000, 1, 0.5)
y <- 0.5 + 0.025 * x + rnorm(1000, 0, sqrt(0.005 * x)) + rnorm(1000, 0, 0.1)
vartest(y, x, type = 2)
#> $coef
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 0.07900124 0.003082579 25.628290 1.030821e-111
#> x 0.01966774 0.004359426 4.511543 7.200682e-06
#>
#> $test
#> F DF P
#> 1 20.35402 1 7.200682e-06
#>