# How to Deal With Betas when variance is Zero?

To calculate a beta, I was using the following formula(Considering $ra$ as returns of $a$ and $rb$ as returns of $b$):

$$\beta = { cov(ra, rb) \over var(rb)}$$

As a software developer, I programmed a function that returns this value. When creating tests, I created some simulated data, thinking that it would have a beta of $0.5$:

$$a = [0.1, 0.2, 0.4, 0.8, 1.6]$$

$$b = [0.1, 0.4, 1.6, 6.4, 12.8]$$

That will result in:

$$ra = [0.6931471805599453, 0.6931471805599453, 0.6931471805599453, 0.6931471805599453]$$

$$rb = [1.3862943611198906, 1.3862943611198906, 1.3862943611198906, 1.3862943611198906]$$

So, when calculating $\beta$, both variance and covariance returned $0$, which resulted in a $NaN$ in Java. I know this is a very very rare case, but even so to me it raises two questions:

1) Is there any convention on which will be $\beta$ value when variance would be $0$?

2) Is the value of $\beta$ even relevant in cases like that?

EDIT: 3) In a software that could use this result to show the user and maybe use in other operations, would it be acceptable to display the data as 0? Or it would be misleading to say this?

• Why are all the elements of rb the same ? – noob2 Jan 31 '18 at 21:36
• 0.6931471805599453 = ln 2. But why 2 and why the logarithm? – noob2 Jan 31 '18 at 22:29
• The problem is that, given your original $a$ and $b$ data, log returns are constant. There isn't really a solution, because with that data there isn't any randomness in returns so beta is not relevant IMO. – Daneel Olivaw Jan 31 '18 at 22:49
• Your answer that it is undefined is correct. For example consider the Beta of $r_a$. covariance would be 0 and variance of $r_a$ would be $> 0$. The $Beta_{r(a)}$ would therefore be 0. I.e., $r_b$ does not depend on $r_a$. – David Addison Jan 31 '18 at 23:15
• @noob2 Well, the $ra$ data is given by $ln(a[i] - a[i - 1])$ for i between 1 and 4. As the $a$ has a change of two times between each item, $ra$ has $ln(2)$ on every position. The same with $rb$, but for $ln(4)$ – Gabryel Monteiro Feb 1 '18 at 1:31