-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
ENH: automatically building contrast/restriction matrices #4361
Comments
annoying implementation detail: We need a sign convention. When we have an ordered set of levels, e.g. A, B, C, do we compute A - B or B - A in the pair comparison?
TukeyHSD displays with two columns group1 group2, and AFAICS (in what I'm doing now) does not create combined labels. |
storing computation for using design_info design matrix for base coefficients. this works manually, but we don't have a standalone t_test function to do this automatically (maybe #3570 or others that I cannot find)
|
parking two list comprehensions, I don't know if they are useful somewhere analogue of triu, all pairwise comparisons
simple product of two lists
|
another case testing: all levels are equal to mean The contrast/restriction should be something like If we want to reuse the models for standalone hypothesis test, then we control the structure of However, we can also just use basic linalg to get cov directly assuming we have Related: Can we handle trend test for ordered categorical exog, or equality null with trend alternative using the models/results? AFAIR, we are still missing standard (standalone) trend tests. |
We have several open issues for this. e.g. #852, #1668, #2362
The attempt that is currently most integrated with patsy is in an extension of #2687 (comment) extension merged in #4365
t_test_pairwise
There is also preliminary code all over the place, but I never managed to figure out a general structure and API
two possibilities using patsy formula factor information and specifying "base contrasts or encoding" explicitly
patsy
patsy attaches the contrast matrix,
cm
below, used to build the encoding, #2687 We don't currently use that information.AFAICS:
diff
) and reparameterized cov_params (where we need only submatrix of cov_params), we can work on selected effects/constraintsarrays and explicit formulas
what do we need?
description of current encoding, e.g. is there a reference level, what is the label for the reference level
labels, column/params indices
target contrast/restriction
mnemonic all pairs, ....
current: ???
coef_restriction_meandiff
for structured penalization or stochastic constraints.contrast_all_one
(which is one of my early attempts)contrastfromcols
to check full rank that I never figured out AFAIRisestimable
which I also never figured outrelated: contrasts/constructed exog for prediction, LSMEANS, margins, ... #2167 and hypothesis tests, inference on linear restrictions of predicted means (like treatment effects)
TODO/Usage:
partially based on what I started in #2687
update in #4365 I combined step 2 "normalize" and step 4 target restriction matrix into a combined restriction matrix that applies to the actual parameterization in the model and can directly be used with t_test and similar.
implementation detail: Where do we put these things?
Aside:
issue ??? suggest using prediction instead of coefficients. This would work for linear prediction (e.g. in GLM) but nonlinear prediction of response would have different effect. Predicted values are likely less close to normal distributed than coefficients, predicted values depend on values of other exog as in margins or predict_at.
prediction and LSMEANS runs into the same problem as here in that we need to construct the auxiliary exog (i.e. artificial sample reflecting the factor levels)
The text was updated successfully, but these errors were encountered: