I have been getting some slightly strange results from the variancePartition package. This prompted me to dig deeper by looking at the output of some of the individual mixed models fitted within. However, the results from
fitVarPartModel() do not match those that I get from running what I think is the same model using
Presumably there is some option/argument that is set differently within variancePartition but I can't figure it out. See example below, based on one given in the variancePartition vignette. Note that some elements of the output are very similar or identical, but for example the residual standard deviation is very different between the two methods. What is different about the two models that I'm fitting that is leading to the different outputs?
# Prepare data library(variancePartition) data(varPartData) weights <- matrix(runif(length(geneExpr)), nrow = nrow(geneExpr)) # Fit model on first two rows of data using variancePartition (get an error if I try to fit a single row) res <- fitVarPartModel(geneExpr[1:2,], ~ (1|Individual) + (1|Tissue) + Age + Height, info, weightsMatrix = weights[1:2,]) # Fit model on first row of data using lme4 resLME <- lmer(geneExpr[1, ] ~ (1|Individual) + (1|Tissue) + Age + Height, data = info, weights = weights[1,], REML = F) # Compare outputs summary(res[])$varcor summary(resLME)$varcor
R version 3.6.1 (2019-07-05) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17763) Matrix products: default Random number generation: RNG: Mersenne-Twister Normal: Inversion Sample: Rounding locale:  LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252  LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C  LC_TIME=English_United Kingdom.1252 attached base packages:  splines parallel stats graphics grDevices utils datasets methods  base other attached packages:  lme4_1.1-21 Matrix_1.2-17 variancePartition_1.14.0  Biobase_2.44.0 BiocGenerics_0.30.0 scales_1.0.0  foreach_1.4.7 limma_3.40.4 ggplot2_3.2.1 loaded via a namespace (and not attached):  progress_1.2.2 gtools_3.8.1 tidyselect_0.2.5 purrr_0.3.2  reshape2_1.4.3 lattice_0.20-38 colorspace_1.4-1 vctrs_0.2.0  rlang_0.4.0 pillar_1.4.2 nloptr_1.2.1 glue_1.3.1  withr_2.1.2 plyr_1.8.4 stringr_1.4.0 munsell_0.5.0  gtable_0.3.0 caTools_18.104.22.168 codetools_0.2-16 doParallel_1.0.15  pbkrtest_0.4-7 Rcpp_1.0.2 KernSmooth_2.23-15 backports_1.1.4  gdata_2.18.0 gplots_22.214.171.124 hms_0.5.1 stringi_1.4.3  dplyr_0.8.3 grid_3.6.1 tools_3.6.1 bitops_1.0-6  magrittr_1.5 lazyeval_0.2.2 tibble_2.1.3 crayon_1.3.4  pkgconfig_2.0.2 zeallot_0.1.0 MASS_7.3-51.4 prettyunits_1.0.2  assertthat_0.2.1 minqa_1.2.4 rstudioapi_0.10 iterators_1.0.12  R6_2.4.0 boot_1.3-23 colorRamps_2.3 nlme_3.1-141  compiler_3.6.1