<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/3d-density-plot-in-r-with-plotly/"></div></div><div><a data-url="http://www.r-bloggers.com/3d-density-plot-in-r-with-plotly/" data-counturl="http://www.r-bloggers.com/3d-density-plot-in-r-with-plotly/" data-count="horizontal" data-text="3D density plot in R with Plotly" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://statisfaction.wordpress.com/2016/06/30/3d-density-plot-in-r-with-plotly/"> R – Statisfaction</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img alt="Plotly_logo_for_digital_final_(6)" class="wp-image-3486" src="http://i2.wp.com/statisfaction.files.wordpress.com/2016/06/plotly_logo_for_digital_final_6.png?resize=359%2C400&ssl=1" data-recalc-dims="1"></p>
<p>In Bayesian nonparametrics, many models address the problem of <em>density regression</em>, including covariate dependent processes. These were settled by the pioneering works by [current ISBA president] <a target="_blank" href="http://aima.eecs.berkeley.edu/~russell/classes/cs294/f05/papers/maceachern-1999.pdf">MacEachern</a> (1999) who introduced the general class of dependent Dirichlet processes. The literature on dependent processes was developed in numerous models, such as nonparametric regression, time series data, meta-analysis, to cite but a few, and applied to a wealth of fields such as, e.g., epidemiology, bioassay problems, genomics, finance. For references, see for instance the chapter by <a target="_blank" href="https://statisfaction.wordpress.com/2015/09/02/who-has-the-biggest-in-bayesian-nonparametrics/">David Dunson</a> in the <a target="_blank" href="http://www.cambridge.org/us/catalogue/catalogue.asp?isbn=9780521513463">Bayesian nonparametrics</a> textbook (edited in 2010 by Nils Lid Hjort, Chris Holmes, Peter Müller and Stephen G. Walker). With Kerrie Mengersen and Judith Rousseau, we have proposed a dependent model in the same vein for modeling the influence of fuel spills on species diversity (<a target="_blank" href="https://arxiv.org/abs/1402.3093">arxiv</a>).</p>
<p>Several densities can be plotted on the same 3D plot thanks to the <a target="_blank" href="https://plot.ly/r/">Plotly R library</a>, <em>“an interactive, browser-based charting library built on the open source JavaScript graphing library, <a target="_blank" href="https://plot.ly/javascript">plotly.js</a>.”</em></p>
<p>In our <a target="_blank" href="https://arxiv.org/abs/1402.3093">ecological example</a>, the model provides a series of densities on the <em>Y</em> axis (in our case, posterior density of species diversity), indexed by some covariate <em>X</em> (a pollutant). See file <a target="_blank" href="https://dl.dropboxusercontent.com/u/1391912/Blog%20statisfaction/data/density_plot.txt">density_plot.txt</a>. The following Plotly R code</p>
<pre>
library(plotly)
mydata = read.csv(&quot;density_plot.txt&quot;)
df = as.data.frame(mydata)
plot_ly(df, x = Y, y = X, z = Z, group = X, type = &quot;scatter3d&quot;, mode = &quot;lines&quot;) 
</pre>
<p>provides a graph as below. For the interactive version, see the RPubs page <a target="_blank" href="http://rpubs.com/julyanarbel/192923">here</a>.</p>
<p><img alt="Capture d’écran 2016-06-30 à 12.15.57" class="wp-image-3457" src="http://i2.wp.com/statisfaction.files.wordpress.com/2016/06/capture-d_ecc81cran-2016-06-30-acc80-12-15-57.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p> </p>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/statisfaction.wordpress.com/3410/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/statisfaction.wordpress.com/3410/" border="0"></a> <img alt="" src="http://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/3d-density-plot-in-r-with-plotly/"></div></div><div><a data-url="http://www.r-bloggers.com/3d-density-plot-in-r-with-plotly/" data-counturl="http://www.r-bloggers.com/3d-density-plot-in-r-with-plotly/" data-count="vertical" data-text="3D density plot in R with Plotly" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://statisfaction.wordpress.com/2016/06/30/3d-density-plot-in-r-with-plotly/"> R – Statisfaction</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://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="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/15LbBP-zC7w"></a></div>