<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/data-pseudo-science-developing-a-biorhythm-calculator/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://r.prevos.net/data-pseudo-science-calculating-biorythm/"> The Devil is in the Data</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a target="_blank" rel="nofollow" href="http://r.prevos.net/?attachment_id=515"><img sizes="(max-width: 300px) 100vw, 300px" data-image-description="" data-orig-file="https://i0.wp.com/r.prevos.net/wp-content/uploads/sites/11/2017/03/biorhythm.png?fit=1631%2C962" data-orig-size="1631,962" data-image-title="biorhythm: data pseudo-science" class="wp-image-515" data-comments-opened="1" data-recalc-dims="1" data-attachment-id="515" data-permalink="http://r.prevos.net/data-pseudo-science-calculating-biorythm/biorhythm/" alt="biorhythm: data pseudo-science" data-medium-file="https://i0.wp.com/r.prevos.net/wp-content/uploads/sites/11/2017/03/biorhythm.png?fit=300%2C177" data-large-file="https://i0.wp.com/r.prevos.net/wp-content/uploads/sites/11/2017/03/biorhythm.png?fit=584%2C344" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" src="https://i0.wp.com/r.prevos.net/wp-content/uploads/sites/11/2017/03/biorhythm.png?resize=300%2C177"></a>Data science is a serious occupation. Just like any other science, however, it can also be used for spurious topics, such as calculating your biorhythm.</p>
<p>This post provides an example of data Pseudo-Science though a function that calculates and visualises your <a target="_blank" rel="nofollow" href="https://en.wikipedia.org/wiki/Biorhythm">biorhythm</a>. Based on the graph, I must be having a great day right now.</p>
<p>The broader and more pertinent message in this post is that data pseudo-science is more common than you would think. Is our belief in machine learning justified or are some of these models also a pseudo-science with not much more reliability than a biorhythm?</p>
<h2>Biorhythm Theory</h2>
<p>The idea that our physical states follow a predetermined rhythm has been around as long as mathematics. The basic concept of biorhythm is that a regular sinusoid cycle accurately describes our physical, emotional and intellectual states. Each of these three cycles has a different wavelength (<img title="w " alt="w " class="latex" src="http://s0.wp.com/latex.php?latex=w+&bg=ffffff&%23038;fg=000&%23038;s=0">):</p>
<ul>
<li>physical: <img title="w = 23 " alt="w = 23 " class="latex" src="http://s0.wp.com/latex.php?latex=w+%3D+23+&bg=ffffff&%23038;fg=000&%23038;s=0"> days</li>
<li>emotional: <img title="w = 28 " alt="w = 28 " class="latex" src="http://s0.wp.com/latex.php?latex=w+%3D+28+&bg=ffffff&%23038;fg=000&%23038;s=0"> days</li>
<li>intellectual: <img title="w = 33 " alt="w = 33 " class="latex" src="http://s0.wp.com/latex.php?latex=w+%3D+33+&bg=ffffff&%23038;fg=000&%23038;s=0"> days</li>
</ul>
<p>The cycle is calculated with <img title="\sin (2 \ pi t / w) " alt="\sin (2 \ pi t / w) " class="latex" src="http://s0.wp.com/latex.php?latex=%5Csin+%282+%5C+pi+t+%2F+w%29+&bg=ffffff&%23038;fg=000&%23038;s=0">, where <img title="t " alt="t " class="latex" src="http://s0.wp.com/latex.php?latex=t+&bg=ffffff&%23038;fg=000&%23038;s=0"> indicates the number of days since birth. This idea was developed by German surgeon Wilhelm Fliess in the late 19<sup>th</sup> century and was popularised in the United States in the late 1970s. There is no scientific evidence of the validity of this theory but it is an entertaining way to play with data.</p>
<p>The combination of the 23- and 28-day cycles repeats every 644 days, while the triple combination of 23-, 28-, and 33-day cycles repeats every 21,252 days, 58 years, two months and three weeks. You can, by the way, never reach a point where all cycles are maximised. The best you can achieve is 299.7 our of a maximum 300 which occurs when you are 17,003 days old.</p>
<h2>Calculating your Biorhythm</h2>
<p>When I was a teenager in the 1980s, several books and <a target="_blank" rel="nofollow" href="http://www.atarimagazines.com/v6n9/Biorhythms.html">magazines</a> described computer code to calculate your biorhythm. I used to play with these functions on my <a target="_blank" rel="nofollow" href="https://en.wikipedia.org/wiki/Atari_8-bit_family">Atari 130XE</a> computer.</p>
<p>Building a biorhythm calculator in R is easy. This function takes two dates as input and plots the biorhythm for the two weeks before and after the date. To calculate your biorhythm, run the function with your date of birth and target date: biorhythm(“yyyy-mm-dd”). The default version uses today as the target.</p>
<pre>
library(ggplot2)
library(reshape2)
biorhythm &lt;- function(dob, target = Sys.Date()) {
    dob &lt;- as.Date(dob)
    target &lt;- as.Date(target)
    t &lt;- round(as.numeric(difftime(target, dob)))
    days &lt;- (t - 14) : (t + 14)
    period &lt;- data.frame(Date = seq.Date(from = target - 15, by = 1, length.out = 29),
                         Physical = sin (2 * pi * days / 23) * 100, 
                         Emotional = sin (2 * pi * days / 28) * 100, 
                         Intellectual = sin (2 * pi * days / 33) * 100)
    period &lt;- melt(period, id.vars = &quot;Date&quot;, variable.name = &quot;Biorhythm&quot;, value.name = &quot;Percentage&quot;)
    ggplot(period, aes(x = Date, y = Percentage, col = Biorhythm)) + geom_line() +  
        ggtitle(paste(&quot;DoB:&quot;, format(dob, &quot;%d %B %Y&quot;))) + 
        geom_vline(xintercept = as.numeric(target))
}

biorhythm(&quot;1969-09-12&quot;, &quot;2017-03-30&quot;)
</pre>
<p>Biorhythms are an early attempt for human beings to predict the future. Although there is no relationship between this algorithm and reality, many people believed in its efficacy. Does the same hold true for the hyped capabilities of machine learning?</p>
<h2>Data Pseudo-Science</h2>
<p>Data pseudo-science is not only an issue when people use spurious mathematical relationships such as biorhythms or astrology. This post is also written as a warning not to only rely on numerical models to predict qualitative aspects of life.</p>
<p>The recent failures in predicting the results of elections, even days before the event, are a case in point. There are many <a target="_blank" rel="nofollow" href="https://www.analyticsvidhya.com/blog/2016/05/8-reasons-analytics-machine-learning-models-fail-deployed/">reasons machine learning methods can go wrong</a>. When machine learning algorithms fail, they are often just as useful as a biorhythm. It would be fun to write a predictive analysis package for R using only pseudoscientific approaches such as I-Ching, astrology or biorhythm.</p>
<p>The post <a target="_blank" rel="nofollow" href="http://r.prevos.net/data-pseudo-science-calculating-biorythm/">Data Pseudo-Science: Developing a Biorhythm Calculator</a> appeared first on <a target="_blank" rel="nofollow" href="http://r.prevos.net/">The Devil is in the Data</a>.</p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://r.prevos.net/data-pseudo-science-calculating-biorythm/"> The Devil is in the Data</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/KbY22tWXU8E"></a></div>