Skip to content

Local FDR, estimation of null Z-score distribution - #2297

Merged
josef-pkt merged 8 commits into
statsmodels:masterfrom
kshedden:local_fdr
Jan 2, 2016
Merged

josef-pkt merged 8 commits into
statsmodels:masterfrom
kshedden:local_fdr

Conversation

@kshedden

@kshedden kshedden commented Mar 1, 2015

Copy link
Copy Markdown
Contributor

This PR implements two techniques from the paper:

B Efron (2008). Microarrays, Empirical Bayes, and the Two-Groups Model. Statistical Science 23:1, 1-22.

The local_fdr function calculates local False Discovery rates from Z-scores. We could possibly implement this as an option within multipletests, but it's nice to have the option to operate on z-scores rather than p-values, which mutlipletests does not allow.

The empirical_null function estimates a non-standard normal distribution based on a set of Z-scores that consists of an unknown mixture of null and non-null hypotheses. It uses a likelihood-based version of the "central matching" idea.

See also #1371.

@josef-pkt

Copy link
Copy Markdown
Member

I will look at it in more detail most likely after next week (spring break for elementary schools here).
Based on the description I have seen something similar in nipy a long time ago, maybe not very close in the details.

two questions after a quick browse

Is there anything specific that exploits z-values, or is it just using the normal instead of the uniform distribution as reference distribution? (p-values as a integral transform)

Would it be better to convert empirical_null to a class so we don't need to hide the nested functions, and can possibly get more returns if needed?

@josef-pkt josef-pkt added this to the 0.8 milestone Mar 1, 2015
@kshedden

kshedden commented Mar 1, 2015

Copy link
Copy Markdown
Contributor Author

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.01%) to 83.92% when pulling 53d8f08 on kshedden:local_fdr into 5dd2502 on statsmodels:master.

Comment thread statsmodels/stats/multitest.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as
np.vander(zbins, deg+?) or vectorized zbins[:, None]**np.arange(deg + 1)
?

@kshedden

kshedden commented Mar 2, 2015

Copy link
Copy Markdown
Contributor Author

Regarding p-values versus z-scores: the local FDR is basically the ratio of the height of the density of null z-scores to the height of the density of all z-scores. So it is not natural to reformulate it in terms of p-values. The density ratio would be different after transforming to p-values. Another difference is that positive and negative effects are treated separately in local FDR.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.01%) to 83.92% when pulling 2d0d5a9 on kshedden:local_fdr into 5dd2502 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.02%) to 83.93% when pulling 2d0d5a9 on kshedden:local_fdr into 5dd2502 on statsmodels:master.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.02%) to 83.93% when pulling 98e7c4a on kshedden:local_fdr into 5dd2502 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member

I'm looking at PRs that should be merged.

Is this ready for review and merge or are there still changes? Is this implementation ok relative to the one in nipy?
I only know the basic idea about this and never went through the details.

@kshedden

Copy link
Copy Markdown
Contributor Author

The model and parameters are the same between our approach and the Nipy approach. But the estimators seem to be different. I am following Efron's approach here, which uses maximum likelihood (restricted to the central part of the distribution). This MLE does not have a closed form, that is why I need to call minimize. The Nipy code is not iterative It probably uses curvature matching around the mode, or perhaps some type of moment matching. It' not that clear from the code, but both these approaches have been used in other FDR work.

Comment thread statsmodels/stats/multitest.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

section header should be Attributes

@josef-pkt

Copy link
Copy Markdown
Member

A few smaller comments, otherwise looks good to merge to me.

I guess we can expand this and share code with similar tasks in future without backwards compatibility problems in the API. The API looks pretty straight forward, but several methods remind me of other things that we don't have yet.

One question on usage: Is there a recommendation for how to z-score the data before calling these functions. e.g. do we need to use a robust variance estimator?
The main usage question, I guess, is how to choose the bounds relative to the z-scoring scale.

@kshedden

Copy link
Copy Markdown
Contributor Author

I think I have accounted for most of these comments. I changed the minimizer to only use the free parameters.

Regarding usage, I think people usually use this approach with a moment-based Z-score. I suppose it could be used with a robust scale estimate but I've never tried that.

Comment thread statsmodels/stats/multitest.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also here switch to an explicit null (0 could just be a numbering, in general)
mean_null sd_null prob_null ?
or maybe without 0 and without null since the name already says it's the Null distribution, and we don't need to add any _null to pdf for consistency.

@josef-pkt

Copy link
Copy Markdown
Member

I finished reading the Efron and the Schwartzman et al (NeuroImage) articles.

I still think EmpiricalNull doesn't sound parametric enough, and I think the trailing 0 are not needed in it's attributes. (EstimatedNull would also sound ok)
(All the deconvolution and outlier/non-null detection comes from the parametric assumption on the Null distribution family.)

The only other issue I have is whether we can extend this to other distributions. Currently names like zscores are targeted to the normal distribution as Null distribution. Schwartzman et al. also allow chisquare distribution (t and F by transformation). Efron transforms F to normal distribution to get zscores, I don't know if that is restrictive with respect to assumptions on degrees of freedom.

@josef-pkt

Copy link
Copy Markdown
Member

@kshedden I just saw by chance that you updated this a few days ago.
I don't get a notification of commits, notifications are sent out when a comment is added. So, please add a comment to the PR if there is something I should look at or merge.

I'll check and merge within a few days, or tonight.

@kshedden

kshedden commented Dec 4, 2015

Copy link
Copy Markdown
Contributor Author

Sure, will do.

Kerby

On Thu, Dec 3, 2015 at 6:21 PM, Josef Perktold [email protected]
wrote:

@kshedden https://github.com/kshedden I just saw by chance that you
updated this a few days ago.
I don't get a notification of commits, notifications are sent out when a
comment is added. So, please add a comment to the PR if there is something
I should look at or merge.

I'll check and merge within a few days, or tonight.

—
Reply to this email directly or view it on GitHub
#2297 (comment)
.

josef-pkt added a commit that referenced this pull request Jan 2, 2016
ENH: Local FDR, estimation of null Z-score distribution
@josef-pkt
josef-pkt merged commit 54d6c2b into statsmodels:master Jan 2, 2016
@josef-pkt

Copy link
Copy Markdown
Member

merged, Sorry for the delay.

@kshedden
kshedden deleted the local_fdr branch July 1, 2016 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants