-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculate F-statistics for Tests of Between-Subjects Effects (Type III, ANOVA) #508
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportBase: 88.75% // Head: 89.38% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #508 +/- ##
==========================================
+ Coverage 88.75% 89.38% +0.63%
==========================================
Files 8 8
Lines 1040 1121 +81
==========================================
+ Hits 923 1002 +79
- Misses 117 119 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
add test for coverage, reference dataset 1 from Schütz, Helmut & Labes, Detlew & Fuglsang, Anders. (2014). Reference Datasets for 2-Treatment, 2-Sequence, 2-Period Bioequivalence Studies. The AAPS journal. 16. 1292-1297. 10.1208/s12248-014-9661-0. |
src/ftest.jl
Outdated
L-contrast matrix for `i` fixed effect. | ||
""" | ||
function lcontrast(obj, i::Int) | ||
n = length(obj.mf.f.rhs.terms) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much of this function relies very heavily on the internal structures of the types from StatsModels. If any internal structures change in StatsModels (which is typically not considered a breaking change in the Julia world) this function will break. StatsModels provides a variety of functions with methods to access these quantities in a stable way; this function should be refactored to use those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I can't find public API from StatsModel documentation to deep work with terms. Can you kindly point me for that ways...
Maybe |
Get rid of TableRegressionModel by storing formula directly in model …
Hi! Maybe if this PR not appropriate to GLM - make it as additional package? |
I have not followed the whole discussion, but I think we should not create a separate package. Rather it would be better to think of the best package to place it into. |
This is draft PR.
This test can be used by users who want ANOVA and can't use F-test for some data (as in my case with crossover designs).
Tests of Between-Subjects Effects included in this PR as it described in SPSS:
F =β' L' (L V L')⁻¹ β L / rank(L)
where V - variance-covariance matrix of β
L-matrix description from SPSS docs (SPSS and SAS docs avialible in public access):
For the inverse of (L V L) used
pinv
because some ofV
matrices are ill-conditioned.Because
V
is Symmetric - I try to calculate it in place and more efficiently.After calculation F for each effect p values are calculated too.
where df - is rank(L)
For
Intercept
factor I think the general mean should be used, but because I can't get the number of efficient levels for InteractionTerm from StatsModel - it is not realized.Also for
InteractionTerm
it may be some issues for zero-intercept models because I don't know how to get completed contrast matrix for this.PrettyTables is used for printing because this is draft PR, it can be removed by custom output.
model used for check:
result:
SPSS result:
data used for check:
PS nested factors are not implemented because they are not implemented in StatsModels. I think SS and MS can be calculated too. The main problem - is a stable method to get real numbers of levels for
InteractionTerm
.