Levene’s test is used to test if the variance between groups is comparable. The test can be used to compare the variances between two groups, but also between more than two groups.
mice
functionThe lbp_orig as part of the miceafter package is a dataset with missing values. So we first impute them with the mice
function. Than we use the mids2milist
function to turn a mids
object with multiply imputed datasets, as a result of using mice
, into a milist
object. Than we use the with
function to apply repeated analyses with the levene_test
function across the list of multiply imputed datasets. Finally, we pool the results by using the pool_levenetest
function.
<- mice(lbp_orig, m=5, seed=3025, printFlag = FALSE)
imp_data
<- mids2milist(imp_data)
imp_list
<- with(data=imp_list,
ra expr = levene_test(Pain ~ factor(Satisfaction)))
<- pool_levenetest(ra, method = "D1")
res
res#> F_value df1 df2 P(>F) RIV
#> [1,] 0.9733556 2 39.1486 0.3867687 0.2869869
#> attr(,"class")
#> [1] "mipool"
mice
function in one PipeThe lbp_orig as part of the miceafter package is a dataset with missing values. So we first impute them with the mice
function. Than we use the mids2milist
function to turn a mids
object with multiply imputed datasets, as a result of using mice
, into a milist
object. Than we use the with
function to apply repeated analyses with the levene_test
function across the list of multiply imputed datasets. Finally, we pool the results by using the pool_levenetest
function.
%>%
lbp_orig mice(m=5, seed=3025, printFlag = FALSE) %>%
mids2milist() %>%
with(expr = levene_test(Pain ~ factor(Satisfaction))) %>%
pool_levenetest(method = "D1")
#> F_value df1 df2 P(>F) RIV
#> [1,] 0.9733556 2 39.1486 0.3867687 0.2869869
#> attr(,"class")
#> [1] "mipool"
The dataset lbpmilr
as part of the miceafter package is a long dataset that contains 10 multiply imputed datasets. The datasets are distinguished by the Impnr
variable. First we convert the dataset into a milist
object by the df2milist
function. Than we use the with
function to apply repeated analyses with the levene_test
function across the multiply imputed datasets. Finally, we pool the results by using the pool_levenetest
function. As pooling method we use D1
(D2
is also possible).
%>%
lbpmilr df2milist(impvar = "Impnr") %>%
with(expr = levene_test(Pain ~ factor(Satisfaction))) %>%
pool_levenetest(method = "D1")
#> F_value df1 df2 P(>F) RIV
#> [1,] 1.014884 2 73.57617 0.3674612 0.3920127
#> attr(,"class")
#> [1] "mipool"