Skip to contents

Formula: R2_c = (sigma2_f + sum sigma2_l) / (sigma2_f + sum sigma2_l + sigma2_e)

Usage

Ccngg(y, X = NULL, Z = NULL, cluster = NULL)

Arguments

y

Response.

X

Fixed-effect design, or NULL.

Z

Ignored; the random effect is the intercept of cluster.

cluster

Grouping factor, or NULL.

Value

List with estimate, r2_marginal, r2_conditional, var_fixed, var_random, var_resid, icc, n, n_groups, method.

Details

The marginal R2 drops the random-effect variance from the numerator and keeps it in the denominator, so it measures what the fixed effects alone explain; the conditional R2 credits both. A residual variance of exactly zero therefore forces R2_c = 1, the degenerate case used to check the algebra. Variance components come from a one-way random-intercept fit by moments.

References

Nakagawa & Schielzeth (2013), Methods Ecol. Evol. 4(2):133-142.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Ccngg(V)
#> $estimate
#> [1] 0
#> 
#> $r2_marginal
#> [1] 0
#> 
#> $r2_conditional
#> [1] 0
#> 
#> $var_fixed
#> [1] 0
#> 
#> $var_random
#> [1] 0
#> 
#> $var_resid
#> [1] 6
#> 
#> $icc
#> [1] 0
#> 
#> $n
#> [1] 8
#> 
#> $n_groups
#> [1] 1
#> 
#> $method
#> [1] "Nakagawa-Schielzeth marginal and conditional R-squared"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"