# How do I estimate the joint probability of stock B moving, if stock A moves?

I have two stocks, A and B, that are correlated in some way.

If I know (hypothetically) that stock A has a 60% chance of rising tomorrow, and I know the joint probability between stocks A and B, how do I calculate the probability of stock B moving tomorrow?

For bonus upvotes - do you know of any standard libraries that can calculate the joint probability of stocks A and B, given a time series of historical data?

Update:

The phrase "conditional probability" is also applicable.

-

So you want to calculate $\mathbb{P}[B_1 > B_0 + \varepsilon \;|\; A_1 > A_0 + \varepsilon]$? If you truly have the joint distribution of $A_1$ and $B_1$ and the current prices $A_0$ and $B_0$, this just becomes a simple exercise in integration, by the definition of probability density. Are you asking how to find a conditional probability in general, or is your question about something else?

-
Interesting. Calculating integrals is not that difficult, thanks or the tip. – Contango Jul 9 '11 at 11:38

Why not using the so simple Monte-Carlo estimator

$\hat{p}_N =\frac{ \sum_{i=1}^N 1_{|A_{i+1}-A_i|>0 \cap |B_{i+1}-B_i|>0}} {\sum_{i=1}^N 1_{|A_{i+1}-A_i|>0 }}$

where $1_{|A_{i+1}-A_i|>0}$ is $1$ if stock $A$ has moved at time $i+1$

-
The main deficiency of this would be if you want a time-varying estimator of conditional probability, since once you've got large $N$, $\hat{p}_N$ would respond very slowly to a sudden clustering of joint positive returns. Here you would want time-varying copulas (not estimated through MLE). – Jase Aug 10 '13 at 13:52

...do you know of any standard libraries that can calculate the joint probability of stocks A and B, given a time series of historical data?

Using R and the LSPM package with the code posted here might be what you are looking for.

-
The LPSM package looks interesting. Thanks! – Contango Aug 11 '13 at 9:54

You can use copulas. The probability that B rises given A rises is $P(- R_B < 0 | - R_A < 0) = \frac{P(-R_B < 0, - R_A < 0)}{P(-R_A < 0)} = \frac{C(F_{-B}(0),F_{-A}(0))}{F_{-A}(0)}$.

You can specify the marginals as a GARCH process and use either non parametric or parametric copulas to get your final conditional probability.

-
Interesting, thanks for the answer! – Contango Aug 11 '13 at 9:54