How a new stability statistic is added so that it fits the package: a core, an exported function, a result with methods, an interpretation, a help page and tests.
Analysis of Variance Table
Response: y
Df Sum Sq Mean Sq F value Pr(>F)
Env 10 263940496 26394050 68.0551 1.995e-08 ***
Rep(Env) 11 4266167 387833
Gen 59 71662431 1214617 12.2482 < 2.2e-16 ***
Gen:Env 590 201336476 341248 3.4411 < 2.2e-16 ***
Residuals 649 64359568 99167
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
.stab_ge_data() gives the table of means, the counts, the combined analysis of variance and the pooled error; .stab_ge_effects() and .stab_svd() the interaction and its decomposition.
3 A new statistic: the coefficient of regression of the interaction
Z <- stability:::.stab_ge_effects(cd$M)I <-colMeans(cd$M) -mean(cd$M)head(x =sort(drop(Z %*% I) /sum(I^2)), n =5)
As an exported function it would check its arguments, wrap the result with .stab_out() (class, label, plot data), define .stab_print_<name>(), .stab_plot_<name>() and an interpreter .stab_int_<name>() with its guide, and come with tests against an independent computation.
4 Summary
Every analysis follows one pattern; a new one reuses the table of means, the error, the result class, the plot theme, the interpretation and the test helpers.