2
$\begingroup$

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?

$\endgroup$
  • 2
    $\begingroup$ Why are all the elements of rb the same ? $\endgroup$ – noob2 Jan 31 '18 at 21:36
  • $\begingroup$ 0.6931471805599453 = ln 2. But why 2 and why the logarithm? $\endgroup$ – noob2 Jan 31 '18 at 22:29
  • 1
    $\begingroup$ 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. $\endgroup$ – Daneel Olivaw Jan 31 '18 at 22:49
  • $\begingroup$ 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$. $\endgroup$ – David Addison Jan 31 '18 at 23:15
  • $\begingroup$ @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)$ $\endgroup$ – Gabryel Monteiro Feb 1 '18 at 1:31
2
$\begingroup$

just responding to your questions:

1) Is there any convention on which will be β value when variance would be 0? -> zero

2) Is the value of β even relevant in cases like that? -> well depends on what you want to use the beta for - if it's only for display, showing zero is OK.

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? -> It should be OK, just copying from wikipedia:

Beta can be zero. Some zero-beta assets are risk-free, such as treasury bonds and cash. However, simply because a beta is zero does not mean that it is risk-free. A beta can be zero simply because the correlation between that item's returns and the market's returns is zero. An example would be betting on horse racing. The correlation with the market will be zero, but it is certainly not a risk-free endeavor.

The only case that I could think of that would match your example is actual cash sitting on an account and not even invested on the risk free rate (since this is not constant either). I guess that better you consult with the business of your app and see if this is actually expected? - if not, your example should just throw an error I guess..

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.