etj has asked for the wisdom of the Perl Monks concerning the following question:

As can be seen at https://github.com/PDLPorters/PDL-Stats/blob/474f0f56dc8cdbe52036a9cf82b7df1058fa7339/t/stats_glm.t#L596-L607, I am trying to fix PDL::Stats's anova functions. You can see in the linked section I have added what I think is the correct MATLAB (in fact Octave) code to replicate the PDL::Stats code, but I am not at all sure.

Can a statistics wizard help a poor stats neophyte out? Especially by creating the right Octave code and checking the tested-for values starting line 623 to tell me what's correct?

  • Comment on Appropriate anova function in MATLAB to check PDL::Stats results?

Replies are listed 'Best First'.
Re: Appropriate anova function in MATLAB to check PDL::Stats results?
by etj (Priest) on Jan 27, 2025 at 01:57 UTC
    A note from the future: as guided by the knowledgeable zmughal, I stopped trying to use MATLAB/Octave, and switched to using R, which is certainly the go-to solution for free statistics software. This is the R equivalent of the test in the given PDL::Stats test file:
    library(data.table) library(rstatix) tdata <- data.frame( stringsAsFactors = FALSE, dv = c(3.0,2.0,1.0,5.0,2.0,1.0,5.0,3.0,1.0,4.0,1.0,2.0,3.0,5.0,5.0,3. +0,4.0,2.0,1.0,5.0,4.0,3.0,2.0,2.0), id = c(0L,1L,2L,3L,0L,1L,2L,3L,0L,1L,2L,3L,0L,1L,2L,3L,0L,1L,2L,3L,0L +,1L,2L,3L), w = c(0L,0L,0L,0L,0L,0L,0L,0L,1L,1L,1L,1L,1L,1L,1L,1L,2L,2L,2L,2L,2L, +2L,2L,2L), b = c(0L,0L,0L,0L,1L,1L,1L,1L,0L,0L,0L,0L,1L,1L,1L,1L,0L,0L,0L,0L,1L, +1L,1L,1L) ) as.data.table(tdata) tdata <- tdata %>% convert_as_factor(id, w, b) as.data.table(tdata) res.aov <- anova_test( data = tdata, dv = dv, wid = id, within = c(w), between = c(b), detailed = TRUE ) res.aov get_anova_table(res.aov, correction = "none")
    And after the code change, PDL::Stats now gives the same results as R! If you want to run the above yourself without "installing" any "software", you can enter it in this extremely handy service: https://rdrr.io/snippets/.
Re: Appropriate anova function in MATLAB to check PDL::Stats results?
by etj (Priest) on Feb 14, 2025 at 18:23 UTC