Skip to content
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

Mugration p-value #153

Open
ktmeaton opened this issue May 3, 2021 · 1 comment
Open

Mugration p-value #153

ktmeaton opened this issue May 3, 2021 · 1 comment

Comments

@ktmeaton
Copy link
Contributor

ktmeaton commented May 3, 2021

Description

I'm tackling the issue of sampling bias in mugration, and was curious if a p-value might be of use here? If I knew the probability of an event happening by chance (given the data) it might guide interpretations.

Disclaimer: I am not a statistician, so if I'm way off, or this is already described, please let me know!

Theory

Given n states s1, s2,... sn with frequencies f1, f2,...fn, what is the probability of observing a transition of sj to sk by chance?

Working Example

What is the probability of observing a mugration event between Russia and Germany by chance? In this example, this probability/p-value is 0.14 and it's up to the user to decide whether that is too high.

import itertools

states = ["Russia", "Lithuania", "Estonia", "Germany"]
frequencies = [4,1,1,2]

observations = []
for s,f in zip(states, frequencies):
	observations += [s] * f
# ['Russia', 'Russia', 'Russia', 'Russia', 'Lithuania', 'Estonia', 'Germany', 'Germany']

transitions = list(itertools.permutations(observations, 2))
transitions_uniq = set(transitions)
# I'm uncertain if "staying in place" should be considered a transition?

target = ("Russia", "Germany")
pvalue = transitions.count(target) / len(transitions)

# Results in a p-value of 0.14
@rneher
Copy link
Member

rneher commented Jun 21, 2021

I guess one thing that one could test is whether particular transitions happen more frequently than expected in a flat transition matrix. But the probabilistic interpretation of mugration models are subtle and first and foremost depend on sampling and the assumption of reversibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants