# Causation vs Correlation: Visualization, Statistics, and Intuition

Visualizations of correlation vs. causation and some common pitfalls and insights involving the statistics are explored in this case study involving stock price time series.

By Alex Jones, Jan 2015.

As someone who has a tendency to think in numbers, I love when success is quantifiable!

So, I looked into

First, I pulled Stock Price over my first ~90 Days, which aligns perfectly with Days Worked.

Then simply added a rolling count of days, how convenient!

Example:

Not so fastâ€¦ letâ€™s Regress Days Worked across Stock Price.

It's important to realize that while visualization is a powerful tool and incredibly insightful way to ingest data, it's not the whole story.

So what do all those numbers really say? Well,

Quick, let's perform some "

First, let'sÂ

How do weÂ

Ok,Â

See how the Orange line (Days worked) currently starts at 0 and goes to 1. Let's flip that. How?

Graphed:

Essentially, we have taken two vectors of differing relative magnitudes, scaled them to an equivalent range and controlled for directionality. Thereby enabling a linear depiction of the relationship and intuitive visualization!

Now what are the regression results?!

Sit down for this...Â

Picture our data as a cube.

If we turn, flip, invert, scale, zoom out, or angle the cube-- has the cube itself changed?Â

We're simply looking at it from a different perspective, we're just finding that perfect angle to tell our story/ visualization.Â

Even with these findings, we must address

However, I bet you there's another variable impacting stock. So what else has happened in the time period?

Well, considering that the company is an oilfield services firm-- we understand the missing link is

What we should realize is that these relationships aren't always obvious! In fact, visualizations can hide relationships!

Added Oil price:

Most importantly, this should exemplify one of the most exciting value potentials of "Big Data". Today, we have access to incredible amounts of information relative to theÂ

As we move towards a smaller and more interconnected world, actively promote "Universal" data points!

This is an abridged version of a post

https://www.linkedin.com/pulse/causation-vs-correlation-alex-jones

Alex JonesÂ is a Graduate Student atÂ U. Texas McCombs School of Business.

As someone who has a tendency to think in numbers, I love when success is quantifiable!

So, I looked into

**how my working**Â**at Cameron relates to the company's stock price**. Alongside this analysis, I'll**demo scaling and data manipulation**to illustrate basic lessons of visualization, statistics, and analysis.First, I pulled Stock Price over my first ~90 Days, which aligns perfectly with Days Worked.

Then simply added a rolling count of days, how convenient!

Example:

**Neat!**Â Letâ€™s graph Stock Price vs Days Worked.**Super!**Â Obviously no relationship!Not so fastâ€¦ letâ€™s Regress Days Worked across Stock Price.

It's important to realize that while visualization is a powerful tool and incredibly insightful way to ingest data, it's not the whole story.

**Blasphemy!****Â**With an**Â****R squared of .88**Â and aÂ**P Value out 42 Decimal Places**, traditional statistics would say we are incredibly confident about the results!So what do all those numbers really say? Well,

**one interpretation****Â**would be:**StockPrice= $75.99 -$.29672(NumberDaysAlexHasWorked)****That's a heck of a deal!**Â I cost a littleÂ**under 30 cents a day...****WRONG.**Â That's per share. With ~197.45M Shares Outstanding, that means,**I cost $58,587,364 per day.****Well, this is awkward...****Â**Quick, let's perform some "

*" to get a "***Transformations***".***Better result**First, let'sÂ

**Scale Stock Price from 0 (lowest) to 1 (highest price)**. To do so, we'll get the Minimum, Maximum value, and Spread.*.***Spread= Maximum - Minimum**How do weÂ

*scale**Â***? Simply, (Stock Price X - Minimum)/ Spread.Â***every datapoint***Boom! Scaled.****Letâ€™s graph!****Great, no relationship!**Â Phew!**Woa**... that doesn't seem right?Â*Letâ€™s also*Scale Days Workedâ€¦Ok,Â

**maybe****Â**there's a relationship...See how the Orange line (Days worked) currently starts at 0 and goes to 1. Let's flip that. How?

**Inverted Days Worked= 1-Scaled Days Worked.**Graphed:

**Holy Moly. I see it now.**Essentially, we have taken two vectors of differing relative magnitudes, scaled them to an equivalent range and controlled for directionality. Thereby enabling a linear depiction of the relationship and intuitive visualization!

**Sorry, thatâ€™s unnecessary.**Now what are the regression results?!

Sit down for this...Â

**The regression results, in absolute terms, are EXACTLY the same**. Even though the equation (on the final graph) is apparently different, once we "undo" the transformations (get numbers to their original values)... theyâ€™ll be the**same!****Why is that?**Â Because w**e didnâ€™t change the overall geometry.**Â We changed all points, not just one point.Picture our data as a cube.

If we turn, flip, invert, scale, zoom out, or angle the cube-- has the cube itself changed?Â

*Absolutely not. It's exactly the same!*We're simply looking at it from a different perspective, we're just finding that perfect angle to tell our story/ visualization.Â

**That's powerful!**Even with these findings, we must address

**Causation vs Correlation!**Â Based on statistics-- "data driven" results, and the interpretation we proposed--Â**I'm the worst!**However, I bet you there's another variable impacting stock. So what else has happened in the time period?

Well, considering that the company is an oilfield services firm-- we understand the missing link is

**price of oil**Â (*I certainly hope!*).What we should realize is that these relationships aren't always obvious! In fact, visualizations can hide relationships!

Added Oil price:

Most importantly, this should exemplify one of the most exciting value potentials of "Big Data". Today, we have access to incredible amounts of information relative to theÂ

**"Universal Variable"-- of time**. With that to relate on, we can see how major indexes, markets, events, weather patterns, etc interrelate!As we move towards a smaller and more interconnected world, actively promote "Universal" data points!

This is an abridged version of a post

https://www.linkedin.com/pulse/causation-vs-correlation-alex-jones

Alex JonesÂ is a Graduate Student atÂ U. Texas McCombs School of Business.

**Related:**