admin管理员组

文章数量:1334704

I am using the lmertree function from the glmertree package to compare the effects of three contexts (levels of a factor called 'source') on acceleration.

Because visual inspection showed heteroscedasticity, I decided to log transform my dependent variable 'acceleration'. Though visual inspection shows improvement, I notice that leveneTest still points to a significant difference.

A colleague suggested using Brown–Forsythe test instead. We both tried but with different functions and obtained different results:

  • Using the bf.test function from 'onewaytests', no significant difference is found.
  • using the leveneTest while specifying the parameter 'center = median' still results in a significant difference.

I am wondering what is causing the difference between the two test results. Many thanks for your help!

Here is the code:

# Add a new column with log-transformed values of acceleration
CA_degrees_PT$log_acce_RHwri_norm_mean <- log(CA_degrees_PT$acce_RHwri_norm_mean)

log_acce_RHwri_norm_mean_lmertree <- lmertree(log_acce_RHwri_norm_mean ~ 1|duration_nFrames + (1|participant)|source , data = CA_degrees_PT) 
plot(log_acce_RHwri_norm_mean_lmertree, which = "tree", gp = gpar(cex = .9))

hist(residuals(log_acce_RHwri_norm_mean_lmertree))

qqnorm(residuals(log_acce_RHwri_norm_mean_lmertree))
qqline(residuals(log_acce_RHwri_norm_mean_lmertree))

resids_log_acce <- residuals(log_acce_RHwri_norm_mean_lmertree)
preds_log_acce <- predict(log_acce_RHwri_norm_mean_lmertree)
plot(CA_degrees_PT$source, resids_log_acce)

leveneTest(resids_log_acce ~ groups, center = median)
bf.test(resids_log_acce ~ groups, data = CA_degrees_PT)

本文标签: