Variance components

varcomp(formula, data)



a two-sided linear formula object describing both the fixed-effects and random-effects part of the model, with the response on the left of a ~ operator and the terms, separated by + operators, on the right. Random-effects terms are distinguished by vertical bars (|) separating expressions for design matrices from grouping factors. Two vertical bars (||) can be used to specify multiple uncorrelated random effects for the same grouping variable. (Because of the way it is implemented, the ||-syntax works only for design matrices containing numeric (continuous) predictors; to fit models with independent categorical effects, see dummy or the lmer_alt function from the afex package.)


a data.frame containing the variables named in `formula`.


data.frame with the variance components in rows


#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>     filter, lag
#> The following objects are masked from 'package:base':
#>     intersect, setdiff, setequal, union
pch <- breast[,c("PCH1_score", "PCH2_score","PCH3_score",
"PCH4_score","PCH5_score")] %>%
mutate(id = 1:nrow(breast))
pch_l <- tidyr::pivot_longer(pch, cols= PCH1_score:PCH5_score,
names_to = "rater", values_to = "score")
varcomp(formula = score ~ (1|id) + (1|rater),  data = pch_l)
#>               grp       vcov
#> id             id 2.34022480
#> rater       rater 0.05026114
#> Residual Residual 0.69131486