<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nicebread</title>
	<atom:link href="http://www.nicebread.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nicebread.de</link>
	<description>Psych &#38; Stats</description>
	<lastBuildDate>Thu, 16 May 2013 07:37:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Installation of WRS package (Wilcox&#8217; Robust Statistics)</title>
		<link>http://www.nicebread.de/installation-of-wrs-package-wilcox-robust-statistics/</link>
		<comments>http://www.nicebread.de/installation-of-wrs-package-wilcox-robust-statistics/#comments</comments>
		<pubDate>Tue, 23 Apr 2013 05:08:27 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[WRS]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=342</guid>
		<description><![CDATA[Some users had trouble installing the WRS package from R-Forge. Here&#8217;s a method that should work automatically and fail-safe: ?View Code RSPLUS# first: install dependent packages install.packages&#40;c&#40;&#34;MASS&#34;, &#34;akima&#34;, &#34;robustbase&#34;&#41;&#41; &#160; # second: install suggested packages install.packages&#40;c&#40;&#34;cobs&#34;, &#34;robust&#34;, &#34;mgcv&#34;, &#34;scatterplot3d&#34;, &#34;quantreg&#34;, &#34;rrcov&#34;, &#34;lars&#34;, &#34;pwr&#34;, &#34;trimcluster&#34;, &#34;parallel&#34;, &#34;mc2d&#34;, &#34;psych&#34;, &#34;Rfit&#34;&#41;&#41; &#160; # third: install WRS install.packages&#40;&#34;WRS&#34;, repos=&#34;http://R-Forge.R-project.org&#34;, [...]]]></description>
				<content:encoded><![CDATA[<p>Some users had trouble installing the WRS package from R-Forge. Here&#8217;s a method that should work automatically and fail-safe:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p342code2'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3422"><td class="code" id="p342code2"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># first: install dependent packages</span>
<span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;MASS&quot;</span>, <span style="color: #ff0000;">&quot;akima&quot;</span>, <span style="color: #ff0000;">&quot;robustbase&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;"># second: install suggested packages</span>
<span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;cobs&quot;</span>, <span style="color: #ff0000;">&quot;robust&quot;</span>, <span style="color: #ff0000;">&quot;mgcv&quot;</span>, <span style="color: #ff0000;">&quot;scatterplot3d&quot;</span>, <span style="color: #ff0000;">&quot;quantreg&quot;</span>, <span style="color: #ff0000;">&quot;rrcov&quot;</span>, <span style="color: #ff0000;">&quot;lars&quot;</span>, <span style="color: #ff0000;">&quot;pwr&quot;</span>, <span style="color: #ff0000;">&quot;trimcluster&quot;</span>, <span style="color: #ff0000;">&quot;parallel&quot;</span>, <span style="color: #ff0000;">&quot;mc2d&quot;</span>, <span style="color: #ff0000;">&quot;psych&quot;</span>, <span style="color: #ff0000;">&quot;Rfit&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
<span style="color: #228B22;"># third: install WRS</span>
<span style="color: #0000FF; font-weight: bold;">install.<span style="">packages</span></span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;WRS&quot;</span>, repos<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;http://R-Forge.R-project.org&quot;</span>, type<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;source&quot;</span><span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>WRS cannot be hosted on CRAN, as CRAN demands help files for every user-visible function. This has not been done for WRS (yet). For the time being, this somewhat more complicated installation routine has to be used.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/installation-of-wrs-package-wilcox-robust-statistics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Further thoughts on post-publication peer review (PPPR)</title>
		<link>http://www.nicebread.de/further-thoughts-on-post-publication-peer-review-pppr/</link>
		<comments>http://www.nicebread.de/further-thoughts-on-post-publication-peer-review-pppr/#comments</comments>
		<pubDate>Tue, 26 Mar 2013 11:51:14 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[Science]]></category>
		<category><![CDATA[peer review]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=314</guid>
		<description><![CDATA[Sanjay Srivastava blogged some interesting thoughts about the process of post-publication peer review (PPPR), reflecting about his own comment on a PLOS ONE publication. I agree that open peer commentaries after publication are one important part of the future of scientific publishing. There were many cases where I wished to have the opportunity to publish [...]]]></description>
				<content:encoded><![CDATA[<p>Sanjay Srivastava <a href="http://hardsci.wordpress.com/2013/03/25/reflections-on-a-foray-into-post-publication-peer-review/">blogged some interesting thoughts</a> about the process of post-publication peer review (PPPR), reflecting about his <a href="http://www.plosone.org/article/comments/info%3Adoi%2F10.1371%2Fjournal.pone.0057989">own comment</a> on a PLOS ONE publication. I agree that open peer commentaries after publication are one important part of the future of scientific publishing. There were many cases where I wished to have the opportunity to publish such a commentary. In one case, I actually wrote a commentary on a paper published in Management Science &#8211; a strange story about managers, age, and testosterone, which received a lot of press coverage. I submitted it as a commentary to the journal, but it was rejected because of &#8220;lack of new results&#8221;. Now my commentary <a href="http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2028882">rests on SSRN</a> and has been downloaded 5 times in 10 months &#8211; yippee-yeah! (probably 3 of these 5 are by myself &#8230;). But as SSRN does <em>not</em> allow peer commentaries I could not set a link from the original paper to my comment, and nobody finds it.</p>
<p>Other fields of science additionally established a <strong>pre</strong>-publication open peer review (also called the &#8220;pre-print culture&#8221;). Many researchers in mathematics or physics publish their preprints on <a href="http://arxiv.org/">arXiv</a> and harvest open peer commentaries before submitting the manuscript to a peer-reviewed journal.</p>
<p><img class="size-medium wp-image-325" align="right" alt="Science Fiction" src="http://www.nicebread.de/WP/wp-content/uploads/2013/03/Bildschirmfoto-2013-03-26-um-12.46.03-300x206.png" width="300" height="206" />I believe devoutly that open PrePPR and PostPPR can significantly improve the quality of scientific output. But one crucial requirement indeed is etiquette, as Sanjay pointed out. I don&#8217;t want to see shitstorms coming over scientific articles, especially in the case of young scholars who worked hard to get their first paper published. Comments should be written in the spirit of a collaborative enhancement of research, and less in terms of &#8220;debunking&#8221;. We all are humans and mistakes can occur. Problems should be pointed out in order to strengthen scientific research, but in a friendly and constructive manner.</p>
<p>Researchers who conceive of science as a highly competitive business where claims have to be fortified and defended might have problems with open peer reviews (e.g., the escalation of the &#8220;Bargh rampage&#8221; [<a href="http://neurobonkers.com/2012/03/08/a-yale-professors-one-man-rampage-against-plos-the-internet-and-a-cambridge-research-group/">1</a>][<a href="http://blogs.discovermagazine.com/notrocketscience/2012/03/10/failed-replication-bargh-psychology-study-doyen/#.UVGHuxlTSH0">2</a>][<a href="http://hardsci.wordpress.com/2012/03/12/some-reflections-on-the-bargh-doyen-elderly-walking-priming-brouhaha/">3</a>]). But if we see science as a collaborative endeavour in search for knowledge, where no model is &#8220;right&#8221; but only &#8220;less wrong&#8221;, open peer reviews can be a very helpful tool.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Some further readings:</p>
<ul>
<li><a href="http://blogs.nature.com/news/2012/08/neanderthal-sex-debate-highlights-benefits-of-pre-publication.html">Neanderthal sex debate highlights benefits of pre-publication </a>(news blog on nature.com)</li>
<li>Interesting <a href="http://dynamicecology.wordpress.com/2012/10/11/in-praise-of-pre-publication-peer-review-because-post-publication-review-is-an-utter-failure/">post</a> by Jeremy Fox (and commenters), argueing for (standard) pre-publication review, from the perspective of marine biology and ecology</li>
<li><a href="http://innge.net/?q=node/330">The case for arXiv and a broader conception of peer-reviews</a> (by Philippe Desjardins-Proulx)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/further-thoughts-on-post-publication-peer-review-pppr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The first CREDAM Award for creative data management goes to &#8230; the German government!</title>
		<link>http://www.nicebread.de/the-first-credam-award-for-creative-data-management-goes-to-the-german-government/</link>
		<comments>http://www.nicebread.de/the-first-credam-award-for-creative-data-management-goes-to-the-german-government/#comments</comments>
		<pubDate>Wed, 06 Mar 2013 09:14:24 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[IRET]]></category>
		<category><![CDATA[Irony]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=296</guid>
		<description><![CDATA[&#8220;If you torture the data long enough, it will confess.&#8221; This aphorism, attributed to Ronald Coase, sometimes has been used in a disrespective manner, as if was wrong to do creative data analysis. This view obviously is misleading. In contrast, we at IRET have a much more positive and humanistic view of data management, and [...]]]></description>
				<content:encoded><![CDATA[<p><em>&#8220;If you torture the data long enough, it will confess.&#8221;</em><br />
This aphorism, attributed to <a href="http://en.wikipedia.org/wiki/Ronald_Coase">Ronald Coase</a>, sometimes has been used in a <a href="http://ignoranceanduncertainty.wordpress.com/2011/09/14/the-stapel-case-and-data-fabrication/">disrespective manner</a>, as if was wrong to do creative data analysis. This view obviously is misleading. In contrast, we at <a title="Amazing fMRI plots for everybody!" href="http://www.nicebread.de/amazing-fmri-plots-for-everybody/">IRET</a> have a much more positive and humanistic view of data management, and therefore we have made this aphorism to our leading guide in difficult times.</p>
<p>We at IRET have made it to our mission to proliferate and foster creative ways of data analysis. Therefore, we proudly introduce an award in recognition of outstanding data creativity: <strong>the CREDAM Award</strong>. CREDAM is both an acronym (<strong>CRE</strong>ative <strong>DA</strong>ta <strong>M</strong>anagement), and a statement: <em>credam (lat.)</em> means &#8220;I will believe&#8221;, or &#8220;I will trust&#8221;.</p>
<h2><span style="text-decoration: underline;">This years CREDAM Award goes to &#8230;&#8230;.. the German government!</span></h2>
<p>A new <a href="http://de.wikipedia.org/wiki/Armuts-_und_Reichtumsbericht_der_Bundesregierung">report on poverty</a> in Germany is going to be published soon. What does the data say?</p>

<table id="tablepress-1-no-2" class="tablepress tablepress-id-1">
<thead>
<tr class="row-1 odd">
	<th class="column-1"><div>Year</div></th><th class="column-2"><div>Overall property in possession of rich households</div></th><th class="column-3"><div>Overall property in possession of complete lower half</div></th>
</tr>
</thead>
<tbody>
<tr class="row-2 even">
	<td class="column-1">1998</td><td class="column-2">45%</td><td class="column-3">3%</td>
</tr>
<tr class="row-3 odd">
	<td class="column-1">2008</td><td class="column-2">53%</td><td class="column-3">1%</td>
</tr>
</tbody>
</table>
<!-- #tablepress-1-no-2 from cache -->
<p>Seems like a pretty clear picture, and in a previous version of the report, the authors concluded (based on this and other data), that <strong>&#8220;income disparity increased&#8221; </strong>(see <a href="http://www.sueddeutsche.de/wirtschaft/armutsbericht-der-regierung-fdp-setzt-sich-mit-beschoenigungen-durch-1.1616717">Süddeutsche Zeitung</a>). But that is wrong!! But why is it wrong? Well, that interpretation &#8220;does not reflect the opinion of the German government&#8221;.</p>
<p>On the pressure of the leader of the minor coalition partner, Philipp Rösler (which currently <a href="http://www.wahlrecht.de/umfragen/index.htm">would be elected</a> by 4% of Germans), this conclusion was re-interpreted. Now, the report comes to the completely opposite conclusion: <strong>&#8220;income disparity <em>decreases</em>&#8220;</strong>!</p>
<h3>As this is a great example of creative data analysis, which liberates us from restrictive and anally retentive &#8220;scientific&#8221; procedures, we are happy to award the first CREDAM trophy to the German government, especially Phillip Rösler. Congratulations!</h3>
<p>(Maybe we should think about adopting this strategy for scientific reports as well. Given <a href="http://pps.sagepub.com/content/7/6/543.abstract">highly flexible approaches</a> of data analysis, conclusions should rather be based on a majority vote of all (co-)authors and reviewers, not on empirical evidence.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/the-first-credam-award-for-creative-data-management-goes-to-the-german-government/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improved evolution of correlations</title>
		<link>http://www.nicebread.de/improve-evolution-of-correlations/</link>
		<comments>http://www.nicebread.de/improve-evolution-of-correlations/#comments</comments>
		<pubDate>Mon, 21 Jan 2013 13:43:32 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[correlation]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[movie]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=287</guid>
		<description><![CDATA[As an update of this post: here&#8217;s an improved version of &#8220;The evolution of correlations&#8221;. From the original post: This is the evolution of a bivariate correlation between two questionnaire scales, “hope of power” and “fear of losing control”. Both scales were administered in an open online study. The video shows how the correlation evolves [...]]]></description>
				<content:encoded><![CDATA[<p>As an update of <a title="The Evolution of Correlations" href="http://www.nicebread.de/the-evolution-of-correlations/">this post</a>: here&#8217;s an improved version of &#8220;The evolution of correlations&#8221;.</p>
<p>From the original post:</p>
<blockquote><p>This is the evolution of a bivariate correlation between two questionnaire scales, “hope of power” and “fear of losing control”. Both scales were administered in an open online study. The video shows how the correlation evolves from r = .69*** (n=20) to r = .26*** (n=271). It does not stabilize until n = 150.</p>
<p>Data has not been rearranged – it is the random order how participants dropped into the study. This had been a rather extreme case of an unstable correlation – other scales in this study were stable right from the beginning. Maybe this video could help as an anecdotal caveat for a careful interpretation of correlations with small n’s (and with ‘small’ I mean n &lt; 100) …</p></blockquote>
<p>The right panel now displays the correlation in each step. The horizontal green line is the final correlation that is approached, the curved dotted line shows the marginal correlation that would be significant at that sample size. As the empirical curve always is above this dotted line, it is significantly different from zero in each step.</p>
<p><iframe src="http://player.vimeo.com/video/57127001?portrait=0" height="366" width="650" allowfullscreen="" frameborder="0"></iframe></p>
<p><a href="http://vimeo.com/57127001">Evolution of correlations &#8211; improved</a> from <a href="http://vimeo.com/user10237274">Felix Schönbrodt</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>&nbsp;</p>
<p>Here the code that created the movie. It&#8217;s not fully self-contained &#8211; the function plotReg plots the dual-panel display, dat0, A, and B are parameters passed to this function. You can insert any other function here. The function loops through the rows of a data frame and saves a plot at every step into a subfolder. Finally, the function needs the command line version of ffmpeg, which connects the pictures to a movie.</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p287code4'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2874"><td class="code" id="p287code4"><pre class="rsplus" style="font-family:monospace;">makeMovie <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/function.html"><span style="color: #0000FF; font-weight: bold;">function</span></a><span style="color: #080;">&#40;</span>fname, dat0, A, B, fps<span style="color: #080;">=</span><span style="color: #ff0000;">15</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
&nbsp;
	<span style="color: #228B22;"># create a new directory for the pictures</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/dir.create.html"><span style="color: #0000FF; font-weight: bold;">dir.<span style="">create</span></span></a><span style="color: #080;">&#40;</span>fname<span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #228B22;"># create the picture sequence</span>
	picName <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/paste.html"><span style="color: #0000FF; font-weight: bold;">paste</span></a><span style="color: #080;">&#40;</span>fname, <span style="color: #ff0000;">&quot;/&quot;</span>, fname, <span style="color: #ff0000;">&quot;_%03d.jpg&quot;</span>, sep<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">jpeg</span></a><span style="color: #080;">&#40;</span>picName, width<span style="color: #080;">=</span><span style="color: #ff0000;">800</span>, height<span style="color: #080;">=</span><span style="color: #ff0000;">450</span>, quality<span style="color: #080;">=</span><span style="color: #ff0000;">95</span><span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/for.html"><span style="color: #0000FF; font-weight: bold;">for</span></a> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">15</span><span style="color: #080;">:</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/nrow.html"><span style="color: #0000FF; font-weight: bold;">nrow</span></a><span style="color: #080;">&#40;</span>dat0<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	  <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/print.html"><span style="color: #0000FF; font-weight: bold;">print</span></a><span style="color: #080;">&#40;</span>i<span style="color: #080;">&#41;</span>
	  plotReg<span style="color: #080;">&#40;</span>A, B, i, keep<span style="color: #080;">=</span><span style="color: #ff0000;">15</span><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">dev.<span style="">off</span></span></a><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #228B22;"># delete any existing movie file</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/unlink.html"><span style="color: #0000FF; font-weight: bold;">unlink</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/paste.html"><span style="color: #0000FF; font-weight: bold;">paste</span></a><span style="color: #080;">&#40;</span>fname,<span style="color: #ff0000;">&quot;.mpg&quot;</span>,sep<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #228B22;"># point system to R's working directory</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/system.html"><span style="color: #0000FF; font-weight: bold;">system</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/paste.html"><span style="color: #0000FF; font-weight: bold;">paste</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;cd &quot;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/gsub.html"><span style="color: #0000FF; font-weight: bold;">gsub</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot; &quot;</span>, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\\</span> &quot;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/getwd.html"><span style="color: #0000FF; font-weight: bold;">getwd</span></a><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>, fixed<span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #228B22;"># show &amp; execute the command line expression for ffmpeg to glue the pictures together</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/print.html"><span style="color: #0000FF; font-weight: bold;">print</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/paste.html"><span style="color: #0000FF; font-weight: bold;">paste</span></a><span style="color: #080;">&#40;</span>paste0<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;ffmpeg -r &quot;</span>, fps, <span style="color: #ff0000;">&quot; -i &quot;</span>, fname, <span style="color: #ff0000;">&quot;/&quot;</span>, fname, <span style="color: #ff0000;">&quot;_%03d.jpg -sameq -r 25 &quot;</span>,  paste0<span style="color: #080;">&#40;</span>fname,<span style="color: #ff0000;">&quot;.avi&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/system.html"><span style="color: #0000FF; font-weight: bold;">system</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/paste.html"><span style="color: #0000FF; font-weight: bold;">paste</span></a><span style="color: #080;">&#40;</span>paste0<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;ffmpeg -r &quot;</span>, fps, <span style="color: #ff0000;">&quot; -i &quot;</span>, fname, <span style="color: #ff0000;">&quot;/&quot;</span>, fname, <span style="color: #ff0000;">&quot;_%03d.jpg -sameq -r 25 &quot;</span>,  paste0<span style="color: #080;">&#40;</span>fname,<span style="color: #ff0000;">&quot;.avi&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/improve-evolution-of-correlations/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Optimizing parameters for an oscillator &#8211; Video</title>
		<link>http://www.nicebread.de/optimizing-parameters-for-an-oscillator-video/</link>
		<comments>http://www.nicebread.de/optimizing-parameters-for-an-oscillator-video/#comments</comments>
		<pubDate>Thu, 10 Jan 2013 10:22:35 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[oscillation]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=278</guid>
		<description><![CDATA[Here&#8217;s a video how the modFit function from the FME package optimizes parameters for an oscillation. A Nelder-Mead-optimizer (R function optim) finds the best fitting parameters for an undampened oscillator. Minimum was found after 72 iterations, true parameter eta was -.05: Evolution of parameters in optimization process from Felix Sch&#246;nbrodt on Vimeo. More on estimating [...]]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s a video how the modFit function from the <a href="http://cran.r-project.org/web/packages/FME/index.html">FME package</a> optimizes parameters for an oscillation. A Nelder-Mead-optimizer (R function optim) finds the best fitting parameters for an undampened oscillator. Minimum was found after 72 iterations, true parameter eta was -.05:<br />
<iframe src="http://player.vimeo.com/video/57124360?portrait=0&amp;loop=0" width="650" height="488" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<p><a href="http://vimeo.com/57124360">Evolution of parameters in optimization process</a> from <a href="http://vimeo.com/user10237274">Felix Sch&ouml;nbrodt</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>More on estimating parameters of differential equations is coming later on this blog!</p>
<p>Things I&#8217;ve learned:</p>
<ul>
<li>ffmpeg does not like pngs. They are internally converted to jpg in a very low quality and I could not find a way to improve this quality. Lesson learned: Export high quality <strong>jpgs</strong> from your R function</li>
<li>Use a standard frame rate for the output file (i.e., 24, 25, or 30 fps)</li>
<li>My final ffmpeg command: <code>ffmpeg -r 10 -i modFit%03d.jpg -r 25 -b:v 5000K modelFit.avi</code>
<ul>
<li>-r 10: Use 10 pictures / second as input</li>
<li>-i modFit%03d.jpg: defines the names of the input files, modFit001.jpg, modFit002.jpg, &#8230;</li>
<li>-r 25: Set framerate of output file to 25 fps</li>
<li>-b:v 5000K: set bitrate of video to a high value</li>
<li>modelFit.mp4: video name and encoding type (mp4)</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/optimizing-parameters-for-an-oscillator-video/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>R-package: Wilcox&#8217; Robust Statistics updated (WRS v0.20)</title>
		<link>http://www.nicebread.de/r-package-wilcox-robust-statistics-updated-wrs-v0-20/</link>
		<comments>http://www.nicebread.de/r-package-wilcox-robust-statistics-updated-wrs-v0-20/#comments</comments>
		<pubDate>Tue, 08 Jan 2013 10:28:32 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[Statistics]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=269</guid>
		<description><![CDATA[Rand Wilcox constantly updates the functions accompanying his books on robust statistics. Recently, they have been updated to version 20. The functions are available in the WRS package for R &#8211; for installation simply type install.packages(&#34;WRS&#34;, repos=&#34;http://R-Forge.R-project.org&#34;) In version 0.20, a number of functions dealing with ANCOVA have been added and some others improved. Unfortunately, [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://dornsife.usc.edu/cf/faculty-and-staff/faculty.cfm?pid=1003819&amp;CFID=6798064&amp;CFTOKEN=96626128">Rand Wilcox</a> constantly updates the functions accompanying his books on robust statistics. Recently, they have been updated to version 20. The functions are available in the <a href="http://r-forge.r-project.org/R/?group_id=468">WRS package</a> for R &#8211; for installation simply type<br />
<code>install.packages(&quot;WRS&quot;, repos=&quot;http://R-Forge.R-project.org&quot;)</code></p>
<p>In version 0.20, a number of functions dealing with ANCOVA have been added and some others improved. Unfortunately, only very few help files exist for the functions. I would recommend to check out the <a href="https://r-forge.r-project.org/scm/viewvc.php/pkg/R/?root=wrs">source code</a>, as most functions have a comment section roughly explaining the parameters. Alternatively, consult Wilcox&#8217; books for descriptions of the functions.</p>
<p><em>References:</em><br />
Wilcox, R. R. (2012). <em>Introduction to Robust Estimation and Hypothesis Testing, 3rd Ed</em>. Academic Press.<br />
Wilcox, R. (2012). <em>Modern Statistics for the Social and Behavioral Sciences: A Practical Introduction.</em> CRC Press.<br />
Wilcox, R. R. (2010). <em>Fundamentals of Modern Statistical Methods: Substantially Improving Power and Accuracy</em>. Springer, 2nd Ed.<br />
Wilcox, R. R. (2009). <em>Basics Statistics: Understanding Conventional Methods and Modern Insights.</em> New York: Oxford.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/r-package-wilcox-robust-statistics-updated-wrs-v0-20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parse pdf files with R (on a Mac)</title>
		<link>http://www.nicebread.de/parse-pdf-files-with-r-on-a-mac/</link>
		<comments>http://www.nicebread.de/parse-pdf-files-with-r-on-a-mac/#comments</comments>
		<pubDate>Thu, 04 Oct 2012 15:11:02 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[R]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=241</guid>
		<description><![CDATA[Inspired by this blog post from theBioBucket, I created a script to parse all pdf files in a directory. Due to its reliance on the Terminal, it&#8217;s Mac specific, but modifications for other systems shouldn&#8217;t be too hard (as a start for Windows, see BioBucket&#8217;s script). First, you have to install the command line tool [...]]]></description>
				<content:encoded><![CDATA[<p>Inspired by this <a href="http://thebiobucket.blogspot.de/2012/09/reading-and-text-mining-pdf-file-in-r.html">blog post</a> from theBioBucket, I created a script to parse all pdf files in a directory. Due to its reliance on the Terminal, it&#8217;s Mac specific, but modifications for other systems shouldn&#8217;t be too hard (as a start for Windows, see BioBucket&#8217;s <a href="https://github.com/gimoya/theBioBucket-Archives/blob/master/R/txtmining_pdf.R">script</a>).</p>
<p>First, you have to install the command line tool <a href="http://www.foolabs.com/xpdf/">pdftotext</a> (a binary can be found on Carsten Blüm&#8217;s <a href="http://www.bluem.net/de/mac/installationspakete/">website</a>). Then, run following script within a directory with pdfs:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p241code6'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2416"><td class="code" id="p241code6"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># helper function: get number of words in a string, separated by tab, space, return, or point.</span>
nwords <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/function.html"><span style="color: #0000FF; font-weight: bold;">function</span></a><span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span><span style="color: #080;">&#123;</span>
	res <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/strsplit.html"><span style="color: #0000FF; font-weight: bold;">strsplit</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/as.character.html"><span style="color: #0000FF; font-weight: bold;">as.<span style="">character</span></span></a><span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span>, <span style="color: #ff0000;">&quot;[ <span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\n</span>,<span style="color: #000099; font-weight: bold;">\\</span>.]+&quot;</span><span style="color: #080;">&#41;</span>
	res <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/lapply.html"><span style="color: #0000FF; font-weight: bold;">lapply</span></a><span style="color: #080;">&#40;</span>res, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/length.html"><span style="color: #0000FF; font-weight: bold;">length</span></a><span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/unlist.html"><span style="color: #0000FF; font-weight: bold;">unlist</span></a><span style="color: #080;">&#40;</span>res<span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;"># sanitize file name for terminal usage (i.e., escape spaces)</span>
sanitize <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/function.html"><span style="color: #0000FF; font-weight: bold;">function</span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">str</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/gsub.html"><span style="color: #0000FF; font-weight: bold;">gsub</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">'([#$%&amp;~_<span style="color: #000099; font-weight: bold;">\\</span>^<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>{}<span style="color: #000099; font-weight: bold;">\\</span>s<span style="color: #000099; font-weight: bold;">\\</span>(<span style="color: #000099; font-weight: bold;">\\</span>)])'</span>, <span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>1'</span>, <span style="color: #0000FF; font-weight: bold;">str</span>, perl <span style="color: #080;">=</span> TRUE<span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<span style="color: #228B22;"># get a list of all files in the current directory</span>
fi <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/list.files.html"><span style="color: #0000FF; font-weight: bold;">list.<span style="">files</span></span></a><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
fi2 <span style="color: #080;">&lt;-</span> fi<span style="color: #080;">&#91;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/grepl.html"><span style="color: #0000FF; font-weight: bold;">grepl</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;.pdf&quot;</span>, fi<span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>
&nbsp;
&nbsp;
<span style="color: #228B22;">## Parse files and do something with it ...</span>
res <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/data.frame.html"><span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span></a><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span> <span style="color: #228B22;"># keeps records of the calculations</span>
<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/for.html"><span style="color: #0000FF; font-weight: bold;">for</span></a> <span style="color: #080;">&#40;</span>f <span style="color: #0000FF; font-weight: bold;">in</span> fi2<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/print.html"><span style="color: #0000FF; font-weight: bold;">print</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/paste.html"><span style="color: #0000FF; font-weight: bold;">paste</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Parsing&quot;</span>, f<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
	f2 <span style="color: #080;">&lt;-</span> sanitize<span style="color: #080;">&#40;</span>f<span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/system.html"><span style="color: #0000FF; font-weight: bold;">system</span></a><span style="color: #080;">&#40;</span>paste0<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;pdftotext &quot;</span>, f2<span style="color: #080;">&#41;</span>, wait <span style="color: #080;">=</span> TRUE<span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #228B22;"># read content of converted txt file</span>
	filetxt <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/sub.html"><span style="color: #0000FF; font-weight: bold;">sub</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;.pdf&quot;</span>, <span style="color: #ff0000;">&quot;.txt&quot;</span>, f<span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/text.html"><span style="color: #0000FF; font-weight: bold;">text</span></a> <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/readLines.html"><span style="color: #0000FF; font-weight: bold;">readLines</span></a><span style="color: #080;">&#40;</span>filetxt, warn<span style="color: #080;">=</span>FALSE<span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #228B22;"># adjust encoding of text - you have to know it</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/Encoding.html"><span style="color: #0000FF; font-weight: bold;">Encoding</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/text.html"><span style="color: #0000FF; font-weight: bold;">text</span></a><span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span> <span style="color: #ff0000;">&quot;latin1&quot;</span>
&nbsp;
	<span style="color: #228B22;"># Do something with the content - here: get word and character count of all pdfs in the current directory</span>
	text2 <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/paste.html"><span style="color: #0000FF; font-weight: bold;">paste</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/text.html"><span style="color: #0000FF; font-weight: bold;">text</span></a>, collapse<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #080;">&#41;</span>	<span style="color: #228B22;"># collapse lines into one long string</span>
&nbsp;
	res <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/rbind.html"><span style="color: #0000FF; font-weight: bold;">rbind</span></a><span style="color: #080;">&#40;</span>res, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/data.frame.html"><span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span></a><span style="color: #080;">&#40;</span>filename<span style="color: #080;">=</span>f, wc<span style="color: #080;">=</span>nwords<span style="color: #080;">&#40;</span>text2<span style="color: #080;">&#41;</span>, cs<span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/nchar.html"><span style="color: #0000FF; font-weight: bold;">nchar</span></a><span style="color: #080;">&#40;</span>text2<span style="color: #080;">&#41;</span>, cs.<span style="">nospace</span><span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/nchar.html"><span style="color: #0000FF; font-weight: bold;">nchar</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/gsub.html"><span style="color: #0000FF; font-weight: bold;">gsub</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>s&quot;</span>, <span style="color: #ff0000;">&quot;&quot;</span>, text2<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> 
&nbsp;
	<span style="color: #228B22;"># remove converted text file</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/file.remove.html"><span style="color: #0000FF; font-weight: bold;">file.<span style="">remove</span></span></a><span style="color: #080;">&#40;</span>filetxt<span style="color: #080;">&#41;</span>
<span style="color: #080;">&#125;</span>
&nbsp;
<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/print.html"><span style="color: #0000FF; font-weight: bold;">print</span></a><span style="color: #080;">&#40;</span>res<span style="color: #080;">&#41;</span></pre></td></tr></table></div>

<p>&#8230; gives following result (wc = word count, cs = characgter count, cs.nospace = character count without spaces):<br />
<pre><code>
&gt; print(res)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filename&nbsp;&nbsp;&nbsp;&nbsp;wc&nbsp;&nbsp;&nbsp;&nbsp; cs cs.nospace
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Applied_Linear_Regression.pdf 33697 186280&nbsp;&nbsp;&nbsp;&nbsp; 154404
2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Baron-rpsych.pdf 22665 128440&nbsp;&nbsp;&nbsp;&nbsp; 105024
3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bootstrapping regressions.pdf&nbsp;&nbsp;6309&nbsp;&nbsp;34042&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;27694
4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ch_multidimensional_scaling.pdf&nbsp;&nbsp; 718&nbsp;&nbsp; 4632&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3908
5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; corrgram.pdf&nbsp;&nbsp;6645&nbsp;&nbsp;40726&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;33965
6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eRm - Extended Rach Modeling (Paper).pdf 11354&nbsp;&nbsp;65273&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;53578
7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eRm (Folien).pdf&nbsp;&nbsp; 371&nbsp;&nbsp; 1407&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;886
8&nbsp;&nbsp;Faraway 2002 - Practical Regression and ANOVA using R.pdf 68777 380902&nbsp;&nbsp;&nbsp;&nbsp; 310037
9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Farnsworth-EconometricsInR.pdf 20482 125207&nbsp;&nbsp;&nbsp;&nbsp; 101157
10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ggplot_book.pdf 10681&nbsp;&nbsp;65388&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;53551
11&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ggplot2-lattice.pdf 18067 118591&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;93737
12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lavaan_usersguide_0.3-1.pdf 12608&nbsp;&nbsp;64232&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;52962
13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lme4 - Bootstrapping.pdf&nbsp;&nbsp;2065&nbsp;&nbsp;11739&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 9515
14&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mclust.pdf 18191&nbsp;&nbsp;92180&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;70848
15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;multcomp.pdf&nbsp;&nbsp;5852&nbsp;&nbsp;38769&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;32344
16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenMxUserGuide.pdf 37320 233817&nbsp;&nbsp;&nbsp;&nbsp; 197571
</code></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/parse-pdf-files-with-r-on-a-mac/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to check your package with R-devel</title>
		<link>http://www.nicebread.de/how-to-check-your-package-with-r-devel/</link>
		<comments>http://www.nicebread.de/how-to-check-your-package-with-r-devel/#comments</comments>
		<pubDate>Wed, 12 Sep 2012 07:17:21 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[CRAN]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[R-devel]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=213</guid>
		<description><![CDATA[In response to an update to ggplot2 (now verson 0.9.2) I had to make some minor changes to our package TripleR. The CRAN maintainers also asked to &#8230; Please also fix other issues that may be apparent in checks with a current R-devel. Now, how can this be done? Here&#8217;s my workflow on Mac OS [...]]]></description>
				<content:encoded><![CDATA[<p>In response to an <a href="https://groups.google.com/forum/#!topic/ggplot2/voXzh-b3M4A">update</a> to ggplot2 (now verson 0.9.2) I had to make some minor changes to our package <a href="http://cran.r-project.org/web/packages/TripleR/index.html">TripleR</a>. The CRAN maintainers also asked to &#8230;</p>
<p><em>Please also fix other issues that may be apparent in checks with a current R-devel.</em></p>
<p>Now, how can this be done? Here&#8217;s my workflow on Mac OS (might be slightly different on Win or Linux):</p>
<ol>
<li>  Install <a href="http://r.research.att.com/">R-devel</a>parallel to your existing (stable) R version
<ol>
<li> Before installation, run <code>sudo pkgutil --forget org.r-project.R.Leopard.fw.pkg</code> in the Terminal, otherwise the installer will overwrite your existing version</li>
<li>Rename your R.app and R64.app or move them temporarily into another folder, as the installer of R-devel probably will replace them by new version that are not compatible with your existing stable R version.</li>
</ol>
</li>
<li>  Use <a href="http://r.research.att.com/#other">RSwitch</a> to change the active R version</li>
<li>  Install packages which your own packages depends on; you have to do it from source, as the binaries for the R-devel do not exist: <code>install.packages(&quot;lme4&quot;, type=&quot;source&quot;)</code></li>
<li> Check your own package using following flag: <code>R CMD check pkg --as-cran</code></li>
<li>Check if your package also works on Windows using <a href="http://win-builder.r-project.org/">winbuilder</a></li>
</ol>
<p>Furthermore, check whether your package follows the <a href="http://cran.r-project.org/web/packages/policies.html">CRAN Repository Policies</a>.</p>
<p>PS: Finally, I managed to get rid of the annoying R CMD check warnings like &#8220;no visible binding for global variable &#8216;x&#8217;&#8221;. These occured due to the ggplot2 syntax. <a href="http://stackoverflow.com/questions/9439256/how-can-i-handle-r-cmd-check-no-visible-binding-for-global-variable-notes-when">Here</a>&#8216;s a solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/how-to-check-your-package-with-r-devel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visually weighted/ Watercolor Plots, new variants: Please vote!</title>
		<link>http://www.nicebread.de/visually-weighted-watercolor-plots-new-variants-please-vote/</link>
		<comments>http://www.nicebread.de/visually-weighted-watercolor-plots-new-variants-please-vote/#comments</comments>
		<pubDate>Thu, 06 Sep 2012 09:19:19 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[dataviz]]></category>
		<category><![CDATA[ggplot2]]></category>
		<category><![CDATA[regression]]></category>
		<category><![CDATA[source code]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=137</guid>
		<description><![CDATA[Update Oct-23: Added a new parameter add to the function. Now multiple groups can be plotted in a single plot (see example in my comment) As a follow-up on my R implementation of Solomon&#8217;s watercolor plots, I made some improvements to the function. I fine-tuned the graphical parameters (the median smoother line now diminishes faster [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Update Oct-23: Added a new parameter <code>add</code> to the function. Now multiple groups can be plotted in a single plot (see example in my <a href="http://www.nicebread.de/visually-weighted-watercolor-plots-new-variants-please-vote/#comment-2061">comment</a>)</strong></p>
<p>As a follow-up on my <a title="Visually weighted regression in R (à la Solomon Hsiang)" href="http://www.nicebread.de/visually-weighted-regression-in-r-a-la-solomon-hsiang/">R implementation</a> of <a href="http://www.fight-entropy.com/2012/08/watercolor-regression.html">Solomon&#8217;s watercolor plots</a>, I made some improvements to the function. I fine-tuned the graphical parameters (the median smoother line now diminishes faster with increasing CIs, and the shaded watercolors look more pretty). Furthermore, the function is faster and has more features:</p>
<ul>
<li>You can define any standard regression function for the bootstrap procedure.
<ul>
<li>vwReg(y ~ x, df, method=lm)</li>
<li>vwReg(y ~ x + I(x^2), df, method=lm)</li>
</ul>
</li>
<li>Provide parameters for the fitting function.
<ul>
<li>You can make the smoother&#8217;s span larger. Then it takes more points into account when doing the local fitting. Per default, the smoother fits a polynomial of degree two &#8211; that means as you increase span you will approach the overall quadratic fit: vwReg(y ~ x, df, span=2)</li>
<li>You can also make the smoother&#8217;s span smaller, then it takes less points for local fitting. If it is too small, it will overfit and approach each single data point. The default span (.75) seemed to be the best choice for me for a variety of data sets: vwReg(y ~ x, df, span=0.5)</li>
<li>Use a robust M-estimator for the smoother; see ?loess for details: vwReg(y ~ x, df, family=&#8221;symmetric&#8221;)</li>
</ul>
</li>
<li>Provide your own color scheme (or, for example, a black-and-white scheme). Examples see pictures below.</li>
<li>Quantize the color ramp, so that regions for 1, 2, and 3 SD have the same color (an idea proposed by <a href="http://www.fight-entropy.com/2012/08/watercolor-regression.html?showComment=1346461906269#c3824969669172879002">John Mashey</a>).</li>
</ul>
<p>At the end of this post is the source code for the R function.</p>
<h2>Some picture &#8211; please vote!</h2>
<p>Here are some variants of the watercolor plots &#8211; at the end, you can vote for your favorite (or write something into the comments). I am still fine-tuning the default parameters, and I am interested in your opinions what would be the best default.</p>
<p><strong>Plot 1: The current default</strong></p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg1.jpeg"><img class="size-full wp-image-163 aligncenter" title="vwReg1" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg1.jpeg" alt="" width="441" height="441" /></a></p>
<p>&nbsp;</p>
<p><strong>Plot 2: Using an M-estimator for bootstrap smoothers.</strong> Usually you get wider confidence intervalls.</p>
<p style="text-align: center;"><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg2.jpeg"><img class="size-full wp-image-164" title="vwReg2" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg2.jpeg" alt="" width="441" height="441" /></a></p>
<p>&nbsp;</p>
<p><strong>Plot 3:Increasing the span of the smoothers</strong></p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg3.jpeg"><img class="aligncenter size-full wp-image-165" title="vwReg3" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg3.jpeg" alt="" width="441" height="441" /></a></p>
<p>&nbsp;</p>
<p><strong>Plot 4: Decreasing the span of the smoothers</strong></p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg4.jpeg"><img class="aligncenter size-full wp-image-166" title="vwReg4" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg4.jpeg" alt="" width="441" height="441" /></a></p>
<p><strong>Plot 5: Changing the color scheme</strong>, using a predefined ColorBrewer palette. You can see all available palettes by using this command: library(RColorBrewer); display.brewer.all()</p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg5.jpeg"><img class="aligncenter size-full wp-image-167" title="vwReg5" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg5.jpeg" alt="" width="441" height="441" /></a></p>
<p>&nbsp;</p>
<p><strong>Plot 6: Using a custom-made palette</strong></p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg6.jpeg"><img class="aligncenter size-full wp-image-168" title="vwReg6" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg6.jpeg" alt="" width="441" height="441" /></a></p>
<p>&nbsp;</p>
<p><strong>Plot 7: Using a custom-made palette;</strong> with the parameter <em>bias</em> you can shift the color ramp to the &#8220;higher&#8221; colors:</p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg7.jpeg"><img class="aligncenter size-full wp-image-169" title="vwReg7" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg7.jpeg" alt="" width="441" height="441" /></a></p>
<p>&nbsp;</p>
<p><strong>Plot 8: A black and white version of the plot</strong></p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg8.jpeg"><img class="aligncenter size-full wp-image-170" title="vwReg8" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg8.jpeg" alt="" width="441" height="441" /></a></p>
<p>&nbsp;</p>
<p><strong>Plot 9: The anti-Tufte-plot</strong>: Using as much ink as possible by reversing black and white (a.k.a. &#8220;<em>the Milky-Way Plot</em>&#8220;)</p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg91.jpeg"><img class="aligncenter size-full wp-image-172" title="vwReg9" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg91.jpeg" alt="" width="441" height="441" /></a></p>
<p><strong>Plot 10: The <em>Northern Light </em>Plot/ fMRI plot.</strong> This plotting technique already has been <a title="Amazing fMRI plots for everybody!" href="http://www.nicebread.de/amazing-fmri-plots-for-everybody/">used</a> by a suspicious company (called <em>IRET</em> &#8211; never heard of that). I hurried to publish the R code under a <a href="http://en.wikipedia.org/wiki/BSD_licenses">FreeBSD</a> license before they can patent it! Feel free to use, share, or change the code for whatever purpose you need. Isn&#8217;t that beautiful?</p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg10.jpeg"><img class="aligncenter size-full wp-image-174" title="vwReg10" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg10.jpeg" alt="" width="441" height="441" /></a></p>
<p><strong>Plot 11: The 1-2-3-SD plot.</strong> You can use your own color schemes as well, e.g.: vwReg(y~x, df, bw=TRUE, quantize=&#8221;SD&#8221;)<strong><br />
</strong></p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg11.jpeg"><img class="aligncenter size-full wp-image-175" title="vwReg11" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/vwReg11.jpeg" alt="" width="441" height="441" /></a></p>
<p>&nbsp;</p>
<p>Any comments or ideas? Or just a vote? If you produce some nice plots with your data, you can send it to me, and I will post a gallery of the most impressive &#8220;data art&#8221;!</p>
<p>Cheers,</p>
<p>Felix</p>
Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code8'); return false;">View Code</a> RSPLUS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1378"><td class="code" id="p137code8"><pre class="rsplus" style="font-family:monospace;"><span style="color: #228B22;"># Copyright 2012 Felix Schönbrodt</span>
<span style="color: #228B22;"># All rights reserved.</span>
<span style="color: #228B22;"># </span>
<span style="color: #228B22;"># FreeBSD License</span>
<span style="color: #228B22;"># </span>
<span style="color: #228B22;"># Redistribution and use in source and binary forms, with or without</span>
<span style="color: #228B22;"># modification, are permitted provided that the following conditions are</span>
<span style="color: #228B22;"># met:</span>
<span style="color: #228B22;"># </span>
<span style="color: #228B22;"># 1. Redistributions of source code must retain the above copyright</span>
<span style="color: #228B22;"># notice, this list of conditions and the following disclaimer.</span>
<span style="color: #228B22;">#       </span>
<span style="color: #228B22;"># 2. Redistributions in binary form must reproduce the above copyright</span>
<span style="color: #228B22;"># notice, this list of conditions and the following disclaimer in the</span>
<span style="color: #228B22;"># documentation and/or other materials provided with the distribution.</span>
<span style="color: #228B22;">#       </span>
<span style="color: #228B22;"># THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER `AS IS'' AND ANY</span>
<span style="color: #228B22;"># EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE</span>
<span style="color: #228B22;"># IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR</span>
<span style="color: #228B22;"># PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR</span>
<span style="color: #228B22;"># CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,</span>
<span style="color: #228B22;"># EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,</span>
<span style="color: #228B22;"># PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR</span>
<span style="color: #228B22;"># PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF</span>
<span style="color: #228B22;"># LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<span style="color: #228B22;"># NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<span style="color: #228B22;"># SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<span style="color: #228B22;"># </span>
<span style="color: #228B22;"># The views and conclusions contained in the software and documentation</span>
<span style="color: #228B22;"># are those of the authors and should not be interpreted as representing</span>
<span style="color: #228B22;"># official policies, either expressed or implied, of the copyright</span>
<span style="color: #228B22;"># holder.</span>
&nbsp;
<span style="color: #228B22;"># Version history:</span>
<span style="color: #228B22;"># 0.1: original code</span>
<span style="color: #228B22;"># 0.1.1: changed license to FreeBSD; re-established compability to ggplot2 (new version 0.9.2)</span>
&nbsp;
<span style="color: #228B22;">## Visually weighted regression / Watercolor plots</span>
<span style="color: #228B22;">## Idea: Solomon Hsiang, with additional ideas from many blog commenters</span>
&nbsp;
&nbsp;
<span style="color: #228B22;"># B = number bootstrapped smoothers</span>
<span style="color: #228B22;"># shade: plot the shaded confidence region?</span>
<span style="color: #228B22;"># shade.alpha: should the CI shading fade out at the edges? (by reducing alpha; 0 = no alpha decrease, 0.1 = medium alpha decrease, 0.5 = strong alpha decrease)</span>
<span style="color: #228B22;"># spag: plot spaghetti lines?</span>
<span style="color: #228B22;"># spag.color: color of spaghetti lines</span>
<span style="color: #228B22;"># mweight: should the median smoother be visually weighted?</span>
<span style="color: #228B22;"># show.lm: should the linear regresison line be plotted?</span>
<span style="color: #228B22;"># show.CI: should the 95% CI limits be plotted?</span>
<span style="color: #228B22;"># show.median: should the median smoother be plotted?</span>
<span style="color: #228B22;"># median.col: color of the median smoother</span>
<span style="color: #228B22;"># shape: shape of points</span>
<span style="color: #228B22;"># method: the fitting function for the spaghettis; default: loess</span>
<span style="color: #228B22;"># bw = TRUE: define a default b&amp;w-palette</span>
<span style="color: #228B22;"># slices: number of slices in x and y direction for the shaded region. Higher numbers make a smoother plot, but takes longer to draw. I wouldn'T go beyond 500</span>
<span style="color: #228B22;"># palette: provide a custom color palette for the watercolors</span>
<span style="color: #228B22;"># ylim: restrict range of the watercoloring</span>
<span style="color: #228B22;"># quantize: either &quot;continuous&quot;, or &quot;SD&quot;. In the latter case, we get three color regions for 1, 2, and 3 SD (an idea of John Mashey)</span>
<span style="color: #228B22;"># add: if add == FALSE, a new ggplot is returned. If add == TRUE, only the elements are returned, which can be added to an existing ggplot (with the '+' operator)</span>
<span style="color: #228B22;"># ...: further parameters passed to the fitting function, in the case of loess, for example, &quot;span = .9&quot;, or &quot;family = 'symmetric'&quot;</span>
vwReg <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/function.html"><span style="color: #0000FF; font-weight: bold;">function</span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">formula</span>, <span style="color: #0000FF; font-weight: bold;">data</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/title.html"><span style="color: #0000FF; font-weight: bold;">title</span></a><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;&quot;</span>, B<span style="color: #080;">=</span><span style="color: #ff0000;">1000</span>, shade<span style="color: #080;">=</span>TRUE, shade.<span style="">alpha</span><span style="color: #080;">=</span>.1, spag<span style="color: #080;">=</span>FALSE, spag.<span style="">color</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;darkblue&quot;</span>, mweight<span style="color: #080;">=</span>TRUE, show.<span style="">lm</span><span style="color: #080;">=</span>FALSE, show.<span style="">median</span> <span style="color: #080;">=</span> TRUE, median.<span style="">col</span> <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;white&quot;</span>, shape <span style="color: #080;">=</span> <span style="color: #ff0000;">21</span>, show.<span style="">CI</span><span style="color: #080;">=</span>FALSE, method<span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">loess</span>, bw<span style="color: #080;">=</span>FALSE, slices<span style="color: #080;">=</span><span style="color: #ff0000;">200</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">palette</span></a><span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">colorRampPalette</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;#FFEDA0&quot;</span>, <span style="color: #ff0000;">&quot;#DD0000&quot;</span><span style="color: #080;">&#41;</span>, bias<span style="color: #080;">=</span><span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">20</span><span style="color: #080;">&#41;</span>, ylim<span style="color: #080;">=</span>NULL, quantize <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;continuous&quot;</span>,  add<span style="color: #080;">=</span>FALSE, ...<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
	IV <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/all.vars.html"><span style="color: #0000FF; font-weight: bold;">all.<span style="">vars</span></span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">formula</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">2</span><span style="color: #080;">&#93;</span>
	DV <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/all.vars.html"><span style="color: #0000FF; font-weight: bold;">all.<span style="">vars</span></span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">formula</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span>
	<span style="color: #0000FF; font-weight: bold;">data</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">na.<span style="">omit</span></span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">&#91;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/order.html"><span style="color: #0000FF; font-weight: bold;">order</span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">&#91;</span>, IV<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span>IV, DV<span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
&nbsp;
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>bw <span style="color: #080;">==</span> TRUE<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		<a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">palette</span></a> <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">colorRampPalette</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;#EEEEEE&quot;</span>, <span style="color: #ff0000;">&quot;#999999&quot;</span>, <span style="color: #ff0000;">&quot;#333333&quot;</span><span style="color: #080;">&#41;</span>, bias<span style="color: #080;">=</span><span style="color: #ff0000;">2</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#40;</span><span style="color: #ff0000;">20</span><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/print.html"><span style="color: #0000FF; font-weight: bold;">print</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Computing boostrapped smoothers ...&quot;</span><span style="color: #080;">&#41;</span>
	newx <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/data.frame.html"><span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/seq.html"><span style="color: #0000FF; font-weight: bold;">seq</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/min.html"><span style="color: #0000FF; font-weight: bold;">min</span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">&#91;</span>, IV<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/max.html"><span style="color: #0000FF; font-weight: bold;">max</span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">&#91;</span>, IV<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/length.html"><span style="color: #0000FF; font-weight: bold;">length</span></a><span style="color: #080;">=</span>slices<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/colnames.html"><span style="color: #0000FF; font-weight: bold;">colnames</span></a><span style="color: #080;">&#40;</span>newx<span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span> IV
	l0.<span style="">boot</span> <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/matrix.html"><span style="color: #0000FF; font-weight: bold;">matrix</span></a><span style="color: #080;">&#40;</span>NA, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/nrow.html"><span style="color: #0000FF; font-weight: bold;">nrow</span></a><span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/nrow.html"><span style="color: #0000FF; font-weight: bold;">nrow</span></a><span style="color: #080;">&#40;</span>newx<span style="color: #080;">&#41;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/ncol.html"><span style="color: #0000FF; font-weight: bold;">ncol</span></a><span style="color: #080;">=</span>B<span style="color: #080;">&#41;</span>
&nbsp;
	l0 <span style="color: #080;">&lt;-</span> method<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">formula</span>, <span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/for.html"><span style="color: #0000FF; font-weight: bold;">for</span></a> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span>B<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		data2 <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">&#91;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/sample.html"><span style="color: #0000FF; font-weight: bold;">sample</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/nrow.html"><span style="color: #0000FF; font-weight: bold;">nrow</span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">&#41;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/replace.html"><span style="color: #0000FF; font-weight: bold;">replace</span></a><span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span>, <span style="color: #080;">&#93;</span>
		data2 <span style="color: #080;">&lt;-</span> data2<span style="color: #080;">&#91;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/order.html"><span style="color: #0000FF; font-weight: bold;">order</span></a><span style="color: #080;">&#40;</span>data2<span style="color: #080;">&#91;</span>, IV<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>, <span style="color: #080;">&#93;</span>
		<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/class.html"><span style="color: #0000FF; font-weight: bold;">class</span></a><span style="color: #080;">&#40;</span>l0<span style="color: #080;">&#41;</span><span style="color: #080;">==</span><span style="color: #ff0000;">&quot;loess&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
			m1 <span style="color: #080;">&lt;-</span> method<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">formula</span>, data2, control <span style="color: #080;">=</span> <span style="color: #0000FF; font-weight: bold;">loess.<span style="">control</span></span><span style="color: #080;">&#40;</span>surface <span style="color: #080;">=</span> <span style="color: #ff0000;">&quot;i&quot;</span>, statistics<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;a&quot;</span>, trace.<span style="">hat</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #080;">&#41;</span>, ...<span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span> <span style="color: #0000FF; font-weight: bold;">else</span> <span style="color: #080;">&#123;</span>
			m1 <span style="color: #080;">&lt;-</span> method<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">formula</span>, data2, ...<span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span>
		l0.<span style="">boot</span><span style="color: #080;">&#91;</span>, i<span style="color: #080;">&#93;</span> <span style="color: #080;">&lt;-</span> <span style="color: #0000FF; font-weight: bold;">predict</span><span style="color: #080;">&#40;</span>m1, newdata<span style="color: #080;">=</span>newx<span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<span style="color: #228B22;"># compute median and CI limits of bootstrap</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/library.html"><span style="color: #0000FF; font-weight: bold;">library</span></a><span style="color: #080;">&#40;</span>plyr<span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/library.html"><span style="color: #0000FF; font-weight: bold;">library</span></a><span style="color: #080;">&#40;</span>reshape2<span style="color: #080;">&#41;</span>
	CI.<span style="">boot</span> <span style="color: #080;">&lt;-</span> adply<span style="color: #080;">&#40;</span>l0.<span style="">boot</span>, <span style="color: #ff0000;">1</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/function.html"><span style="color: #0000FF; font-weight: bold;">function</span></a><span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span> <span style="color: #0000FF; font-weight: bold;">quantile</span><span style="color: #080;">&#40;</span>x, prob<span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span>.025, .5, .975, <span style="color: #0000FF; font-weight: bold;">pnorm</span><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #080;">-</span><span style="color: #ff0000;">3</span>, <span style="color: #080;">-</span><span style="color: #ff0000;">2</span>, <span style="color: #080;">-</span><span style="color: #ff0000;">1</span>, <span style="color: #ff0000;">0</span>, <span style="color: #ff0000;">1</span>, <span style="color: #ff0000;">2</span>, <span style="color: #ff0000;">3</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>, na.<span style="">rm</span><span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#91;</span>, <span style="color: #080;">-</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/colnames.html"><span style="color: #0000FF; font-weight: bold;">colnames</span></a><span style="color: #080;">&#40;</span>CI.<span style="">boot</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">10</span><span style="color: #080;">&#93;</span> <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;LL&quot;</span>, <span style="color: #ff0000;">&quot;M&quot;</span>, <span style="color: #ff0000;">&quot;UL&quot;</span>, paste0<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;SD&quot;</span>, <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">7</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
	CI.<span style="">boot</span>$x <span style="color: #080;">&lt;-</span> newx<span style="color: #080;">&#91;</span>, <span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span>
	CI.<span style="">boot</span>$width <span style="color: #080;">&lt;-</span> CI.<span style="">boot</span>$UL <span style="color: #080;">-</span> CI.<span style="">boot</span>$LL
&nbsp;
	<span style="color: #228B22;"># scale the CI width to the range 0 to 1 and flip it (bigger numbers = narrower CI)</span>
	CI.<span style="">boot</span>$w2 <span style="color: #080;">&lt;-</span> <span style="color: #080;">&#40;</span>CI.<span style="">boot</span>$width <span style="color: #080;">-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/min.html"><span style="color: #0000FF; font-weight: bold;">min</span></a><span style="color: #080;">&#40;</span>CI.<span style="">boot</span>$width<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
	CI.<span style="">boot</span>$w3 <span style="color: #080;">&lt;-</span> <span style="color: #ff0000;">1</span><span style="color: #080;">-</span><span style="color: #080;">&#40;</span>CI.<span style="">boot</span>$w2<span style="color: #080;">/</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/max.html"><span style="color: #0000FF; font-weight: bold;">max</span></a><span style="color: #080;">&#40;</span>CI.<span style="">boot</span>$w2<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
&nbsp;
	<span style="color: #228B22;"># convert bootstrapped spaghettis to long format</span>
	b2 <span style="color: #080;">&lt;-</span> melt<span style="color: #080;">&#40;</span>l0.<span style="">boot</span><span style="color: #080;">&#41;</span>
	b2$x <span style="color: #080;">&lt;-</span> newx<span style="color: #080;">&#91;</span>,<span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/colnames.html"><span style="color: #0000FF; font-weight: bold;">colnames</span></a><span style="color: #080;">&#40;</span>b2<span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;index&quot;</span>, <span style="color: #ff0000;">&quot;B&quot;</span>, <span style="color: #ff0000;">&quot;value&quot;</span>, <span style="color: #ff0000;">&quot;x&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/library.html"><span style="color: #0000FF; font-weight: bold;">library</span></a><span style="color: #080;">&#40;</span>ggplot2<span style="color: #080;">&#41;</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/library.html"><span style="color: #0000FF; font-weight: bold;">library</span></a><span style="color: #080;">&#40;</span>RColorBrewer<span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #228B22;"># Construct ggplot</span>
	<span style="color: #228B22;"># All plot elements are constructed as a list, so they can be added to an existing ggplot</span>
&nbsp;
	<span style="color: #228B22;"># if add == FALSE: provide the basic ggplot object</span>
	p0 <span style="color: #080;">&lt;-</span> ggplot<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span>, aes_string<span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>IV, y<span style="color: #080;">=</span>DV<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">+</span> theme_bw<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
&nbsp;
	<span style="color: #228B22;"># initialize elements with NULL (if they are defined, they are overwritten with something meaningful)</span>
	gg.<span style="">tiles</span> <span style="color: #080;">&lt;-</span> gg.<span style="">poly</span> <span style="color: #080;">&lt;-</span> gg.<span style="">spag</span> <span style="color: #080;">&lt;-</span> gg.<span style="">median</span> <span style="color: #080;">&lt;-</span> gg.<span style="">CI1</span> <span style="color: #080;">&lt;-</span> gg.<span style="">CI2</span> <span style="color: #080;">&lt;-</span> gg.<span style="">lm</span> <span style="color: #080;">&lt;-</span> gg.<span style="">points</span> <span style="color: #080;">&lt;-</span> gg.<span style="">title</span> <span style="color: #080;">&lt;-</span> NULL
&nbsp;
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>shade <span style="color: #080;">==</span> TRUE<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		quantize <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/match.arg.html"><span style="color: #0000FF; font-weight: bold;">match.<span style="">arg</span></span></a><span style="color: #080;">&#40;</span>quantize, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;continuous&quot;</span>, <span style="color: #ff0000;">&quot;SD&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
		<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>quantize <span style="color: #080;">==</span> <span style="color: #ff0000;">&quot;continuous&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
			<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/print.html"><span style="color: #0000FF; font-weight: bold;">print</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Computing density estimates for each vertical cut ...&quot;</span><span style="color: #080;">&#41;</span>
			<span style="color: #0000FF; font-weight: bold;">flush.<span style="">console</span></span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
&nbsp;
			<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/is.null.html"><span style="color: #0000FF; font-weight: bold;">is.<span style="">null</span></span></a><span style="color: #080;">&#40;</span>ylim<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
				min_value <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/min.html"><span style="color: #0000FF; font-weight: bold;">min</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/min.html"><span style="color: #0000FF; font-weight: bold;">min</span></a><span style="color: #080;">&#40;</span>l0.<span style="">boot</span>, na.<span style="">rm</span><span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/min.html"><span style="color: #0000FF; font-weight: bold;">min</span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">&#91;</span>, DV<span style="color: #080;">&#93;</span>, na.<span style="">rm</span><span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
				max_value <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/max.html"><span style="color: #0000FF; font-weight: bold;">max</span></a><span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/max.html"><span style="color: #0000FF; font-weight: bold;">max</span></a><span style="color: #080;">&#40;</span>l0.<span style="">boot</span>, na.<span style="">rm</span><span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/max.html"><span style="color: #0000FF; font-weight: bold;">max</span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">&#91;</span>, DV<span style="color: #080;">&#93;</span>, na.<span style="">rm</span><span style="color: #080;">=</span>TRUE<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
				ylim <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span>min_value, max_value<span style="color: #080;">&#41;</span>
			<span style="color: #080;">&#125;</span>
&nbsp;
			<span style="color: #228B22;"># vertical cross-sectional density estimate</span>
			d2 <span style="color: #080;">&lt;-</span> ddply<span style="color: #080;">&#40;</span>b2<span style="color: #080;">&#91;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;x&quot;</span>, <span style="color: #ff0000;">&quot;value&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>, .<span style="color: #080;">&#40;</span>x<span style="color: #080;">&#41;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/function.html"><span style="color: #0000FF; font-weight: bold;">function</span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">df</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
				res <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/data.frame.html"><span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span></a><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">density</span><span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">df</span>$value, na.<span style="">rm</span><span style="color: #080;">=</span>TRUE, n<span style="color: #080;">=</span>slices, from<span style="color: #080;">=</span>ylim<span style="color: #080;">&#91;</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#93;</span>, to<span style="color: #080;">=</span>ylim<span style="color: #080;">&#91;</span><span style="color: #ff0000;">2</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#91;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;x&quot;</span>, <span style="color: #ff0000;">&quot;y&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
				<span style="color: #228B22;">#res &lt;- data.frame(density(df$value, na.rm=TRUE, n=slices)[c(&quot;x&quot;, &quot;y&quot;)])</span>
				<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/colnames.html"><span style="color: #0000FF; font-weight: bold;">colnames</span></a><span style="color: #080;">&#40;</span>res<span style="color: #080;">&#41;</span> <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;y&quot;</span>, <span style="color: #ff0000;">&quot;dens&quot;</span><span style="color: #080;">&#41;</span>
				<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/return.html"><span style="color: #0000FF; font-weight: bold;">return</span></a><span style="color: #080;">&#40;</span>res<span style="color: #080;">&#41;</span>
			<span style="color: #080;">&#125;</span>, .<span style="">progress</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #080;">&#41;</span>
&nbsp;
			maxdens <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/max.html"><span style="color: #0000FF; font-weight: bold;">max</span></a><span style="color: #080;">&#40;</span>d2$dens<span style="color: #080;">&#41;</span>
			mindens <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/min.html"><span style="color: #0000FF; font-weight: bold;">min</span></a><span style="color: #080;">&#40;</span>d2$dens<span style="color: #080;">&#41;</span>
			d2$dens.<span style="">scaled</span> <span style="color: #080;">&lt;-</span> <span style="color: #080;">&#40;</span>d2$dens <span style="color: #080;">-</span> mindens<span style="color: #080;">&#41;</span><span style="color: #080;">/</span>maxdens	
&nbsp;
			<span style="color: #228B22;">## Tile approach</span>
			d2$alpha.<span style="">factor</span> <span style="color: #080;">&lt;-</span> d2$dens.<span style="">scaled</span><span style="color: #080;">^</span>shade.<span style="">alpha</span>
			gg.<span style="">tiles</span> <span style="color: #080;">&lt;-</span>  <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/list.html"><span style="color: #0000FF; font-weight: bold;">list</span></a><span style="color: #080;">&#40;</span>geom_tile<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span>d2, aes<span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>x, y<span style="color: #080;">=</span>y, fill<span style="color: #080;">=</span>dens.<span style="">scaled</span>, alpha<span style="color: #080;">=</span>alpha.<span style="">factor</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>, scale_fill_gradientn<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;dens.scaled&quot;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">colours</span></a><span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">palette</span></a><span style="color: #080;">&#41;</span>, scale_alpha_continuous<span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/range.html"><span style="color: #0000FF; font-weight: bold;">range</span></a><span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">0.001</span>, <span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span>
		<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>quantize <span style="color: #080;">==</span> <span style="color: #ff0000;">&quot;SD&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
			<span style="color: #228B22;">## Polygon approach</span>
&nbsp;
			SDs <span style="color: #080;">&lt;-</span> melt<span style="color: #080;">&#40;</span>CI.<span style="">boot</span><span style="color: #080;">&#91;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;x&quot;</span>, paste0<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;SD&quot;</span>, <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">7</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#93;</span>, id.<span style="">vars</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;x&quot;</span><span style="color: #080;">&#41;</span>
			count <span style="color: #080;">&lt;-</span> <span style="color: #ff0000;">0</span>
			d3 <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/data.frame.html"><span style="color: #0000FF; font-weight: bold;">data.<span style="">frame</span></span></a><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
			<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/col.html"><span style="color: #0000FF; font-weight: bold;">col</span></a> <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/c.html"><span style="color: #0000FF; font-weight: bold;">c</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">1</span>,<span style="color: #ff0000;">2</span>,<span style="color: #ff0000;">3</span>,<span style="color: #ff0000;">3</span>,<span style="color: #ff0000;">2</span>,<span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>
			<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/for.html"><span style="color: #0000FF; font-weight: bold;">for</span></a> <span style="color: #080;">&#40;</span>i <span style="color: #0000FF; font-weight: bold;">in</span> <span style="color: #ff0000;">1</span><span style="color: #080;">:</span><span style="color: #ff0000;">6</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
				seg1 <span style="color: #080;">&lt;-</span> SDs<span style="color: #080;">&#91;</span>SDs$variable <span style="color: #080;">==</span> paste0<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;SD&quot;</span>, i<span style="color: #080;">&#41;</span>, <span style="color: #080;">&#93;</span>
				seg2 <span style="color: #080;">&lt;-</span> SDs<span style="color: #080;">&#91;</span>SDs$variable <span style="color: #080;">==</span> paste0<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;SD&quot;</span>, i<span style="color: #080;">+</span><span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span>, <span style="color: #080;">&#93;</span>
				seg <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/rbind.html"><span style="color: #0000FF; font-weight: bold;">rbind</span></a><span style="color: #080;">&#40;</span>seg1, seg2<span style="color: #080;">&#91;</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/nrow.html"><span style="color: #0000FF; font-weight: bold;">nrow</span></a><span style="color: #080;">&#40;</span>seg2<span style="color: #080;">&#41;</span><span style="color: #080;">:</span><span style="color: #ff0000;">1</span>, <span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
				seg$group <span style="color: #080;">&lt;-</span> count
				seg$col <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/col.html"><span style="color: #0000FF; font-weight: bold;">col</span></a><span style="color: #080;">&#91;</span>i<span style="color: #080;">&#93;</span>
				count <span style="color: #080;">&lt;-</span> count <span style="color: #080;">+</span> <span style="color: #ff0000;">1</span>
				d3 <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/rbind.html"><span style="color: #0000FF; font-weight: bold;">rbind</span></a><span style="color: #080;">&#40;</span>d3, seg<span style="color: #080;">&#41;</span>
			<span style="color: #080;">&#125;</span>
&nbsp;
			gg.<span style="">poly</span> <span style="color: #080;">&lt;-</span>  <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/list.html"><span style="color: #0000FF; font-weight: bold;">list</span></a><span style="color: #080;">&#40;</span>geom_polygon<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span>d3, aes<span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>x, y<span style="color: #080;">=</span>value, color<span style="color: #080;">=</span>NULL, fill<span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/col.html"><span style="color: #0000FF; font-weight: bold;">col</span></a>, group<span style="color: #080;">=</span>group<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>, scale_fill_gradientn<span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;dens.scaled&quot;</span>, <a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">colours</span></a><span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/summary.lm.html"><span style="color: #0000FF; font-weight: bold;">palette</span></a>, values<span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/seq.html"><span style="color: #0000FF; font-weight: bold;">seq</span></a><span style="color: #080;">&#40;</span><span style="color: #080;">-</span><span style="color: #ff0000;">1</span>, <span style="color: #ff0000;">3</span>, <span style="color: #ff0000;">1</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/print.html"><span style="color: #0000FF; font-weight: bold;">print</span></a><span style="color: #080;">&#40;</span><span style="color: #ff0000;">&quot;Build ggplot figure ...&quot;</span><span style="color: #080;">&#41;</span>
	<span style="color: #0000FF; font-weight: bold;">flush.<span style="">console</span></span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
&nbsp;
&nbsp;
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>spag<span style="color: #080;">==</span>TRUE<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		gg.<span style="">spag</span> <span style="color: #080;">&lt;-</span>  geom_path<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span>b2, aes<span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>x, y<span style="color: #080;">=</span>value, group<span style="color: #080;">=</span>B<span style="color: #080;">&#41;</span>, size<span style="color: #080;">=</span><span style="color: #ff0000;">0.7</span>, alpha<span style="color: #080;">=</span><span style="color: #ff0000;">10</span><span style="color: #080;">/</span>B, color<span style="color: #080;">=</span>spag.<span style="">color</span><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>show.<span style="">median</span> <span style="color: #080;">==</span> TRUE<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>mweight <span style="color: #080;">==</span> TRUE<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
			gg.<span style="">median</span> <span style="color: #080;">&lt;-</span>  geom_path<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span>CI.<span style="">boot</span>, aes<span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>x, y<span style="color: #080;">=</span>M, alpha<span style="color: #080;">=</span>w3<span style="color: #080;">^</span><span style="color: #ff0000;">3</span><span style="color: #080;">&#41;</span>, size<span style="color: #080;">=</span>.6, linejoin<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;mitre&quot;</span>, color<span style="color: #080;">=</span>median.<span style="">col</span><span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span> <span style="color: #0000FF; font-weight: bold;">else</span> <span style="color: #080;">&#123;</span>
			gg.<span style="">median</span> <span style="color: #080;">&lt;-</span>  geom_path<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span>CI.<span style="">boot</span>, aes<span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>x, y<span style="color: #080;">=</span>M<span style="color: #080;">&#41;</span>, size <span style="color: #080;">=</span> <span style="color: #ff0000;">0.6</span>, linejoin<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;mitre&quot;</span>, color<span style="color: #080;">=</span>median.<span style="">col</span><span style="color: #080;">&#41;</span>
		<span style="color: #080;">&#125;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<span style="color: #228B22;"># Confidence limits</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>show.<span style="">CI</span> <span style="color: #080;">==</span> TRUE<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		gg.<span style="">CI1</span> <span style="color: #080;">&lt;-</span> geom_path<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span>CI.<span style="">boot</span>, aes<span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>x, y<span style="color: #080;">=</span>UL<span style="color: #080;">&#41;</span>, size<span style="color: #080;">=</span><span style="color: #ff0000;">1</span>, color<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;red&quot;</span><span style="color: #080;">&#41;</span>
		gg.<span style="">CI2</span> <span style="color: #080;">&lt;-</span> geom_path<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span>CI.<span style="">boot</span>, aes<span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>x, y<span style="color: #080;">=</span>LL<span style="color: #080;">&#41;</span>, size<span style="color: #080;">=</span><span style="color: #ff0000;">1</span>, color<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;red&quot;</span><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
	<span style="color: #228B22;"># plain linear regression line</span>
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>show.<span style="">lm</span><span style="color: #080;">==</span>TRUE<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>gg.<span style="">lm</span> <span style="color: #080;">&lt;-</span> geom_smooth<span style="color: #080;">&#40;</span>method<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;lm&quot;</span>, color<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;darkgreen&quot;</span>, se<span style="color: #080;">=</span>FALSE<span style="color: #080;">&#41;</span><span style="color: #080;">&#125;</span>
&nbsp;
	gg.<span style="">points</span> <span style="color: #080;">&lt;-</span> geom_point<span style="color: #080;">&#40;</span><span style="color: #0000FF; font-weight: bold;">data</span><span style="color: #080;">=</span><span style="color: #0000FF; font-weight: bold;">data</span>, aes_string<span style="color: #080;">&#40;</span>x<span style="color: #080;">=</span>IV, y<span style="color: #080;">=</span>DV<span style="color: #080;">&#41;</span>, size<span style="color: #080;">=</span><span style="color: #ff0000;">1</span>, shape<span style="color: #080;">=</span>shape, fill<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;white&quot;</span>, color<span style="color: #080;">=</span><span style="color: #ff0000;">&quot;black&quot;</span><span style="color: #080;">&#41;</span>		
&nbsp;
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/title.html"><span style="color: #0000FF; font-weight: bold;">title</span></a> <span style="color: #080;">!=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		gg.<span style="">title</span> <span style="color: #080;">&lt;-</span> theme<span style="color: #080;">&#40;</span><a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/title.html"><span style="color: #0000FF; font-weight: bold;">title</span></a><span style="color: #080;">=</span><a href="http://astrostatistics.psu.edu/su07/R/html/stats/html/title.html"><span style="color: #0000FF; font-weight: bold;">title</span></a><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
&nbsp;
&nbsp;
	gg.<span style="">elements</span> <span style="color: #080;">&lt;-</span> <a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/list.html"><span style="color: #0000FF; font-weight: bold;">list</span></a><span style="color: #080;">&#40;</span>gg.<span style="">tiles</span>, gg.<span style="">poly</span>, gg.<span style="">spag</span>, gg.<span style="">median</span>, gg.<span style="">CI1</span>, gg.<span style="">CI2</span>, gg.<span style="">lm</span>, gg.<span style="">points</span>, gg.<span style="">title</span>, theme<span style="color: #080;">&#40;</span>legend.<span style="">position</span><span style="color: #080;">=</span><span style="color: #ff0000;">&quot;none&quot;</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>
&nbsp;
	<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/if.html"><span style="color: #0000FF; font-weight: bold;">if</span></a> <span style="color: #080;">&#40;</span>add <span style="color: #080;">==</span> FALSE<span style="color: #080;">&#41;</span> <span style="color: #080;">&#123;</span>
		<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/return.html"><span style="color: #0000FF; font-weight: bold;">return</span></a><span style="color: #080;">&#40;</span>p0 <span style="color: #080;">+</span> gg.<span style="">elements</span><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span> <span style="color: #0000FF; font-weight: bold;">else</span> <span style="color: #080;">&#123;</span>
		<a href="http://astrostatistics.psu.edu/su07/R/html/graphics/html/return.html"><span style="color: #0000FF; font-weight: bold;">return</span></a><span style="color: #080;">&#40;</span>gg.<span style="">elements</span><span style="color: #080;">&#41;</span>
	<span style="color: #080;">&#125;</span>
<span style="color: #080;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/visually-weighted-watercolor-plots-new-variants-please-vote/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Amazing fMRI plots for everybody!</title>
		<link>http://www.nicebread.de/amazing-fmri-plots-for-everybody/</link>
		<comments>http://www.nicebread.de/amazing-fmri-plots-for-everybody/#comments</comments>
		<pubDate>Wed, 05 Sep 2012 09:26:59 +0000</pubDate>
		<dc:creator>FelixS</dc:creator>
				<category><![CDATA[IRET]]></category>
		<category><![CDATA[Psych]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[Statistics]]></category>
		<category><![CDATA[dataviz]]></category>
		<category><![CDATA[fMRI]]></category>
		<category><![CDATA[ggplot2]]></category>

		<guid isPermaLink="false">http://www.nicebread.de/?p=139</guid>
		<description><![CDATA[Dear valued customer, it is a well-known scientific truth that research results which are accompanied by a fancy, colorful fMRI scan, are perceived as more believable and more persuasive than simple bar graphs or text results (McCabe &#38; Castel, 2007; Weisberg, Keil, Goodstein, Rawson, &#38; Gray, 2008). Readers even agree more with fictitious and unsubstantiated [...]]]></description>
				<content:encoded><![CDATA[<p>Dear valued customer,</p>
<p>it is a well-known scientific truth that research results which are accompanied by a fancy, colorful fMRI scan, are perceived as more believable and more persuasive than simple bar graphs or text results (<a href="http://www.sciencedirect.com/science/article/pii/S0010027707002053">McCabe &amp; Castel, 2007</a>; <a href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2778755/">Weisberg, Keil, Goodstein, Rawson, &amp; Gray, 2008</a>). Readers even agree more with fictitious and unsubstantiated claims, as long as you provide a colorful brain image, and it works even when the subject is a <a href="http://prefrontal.org/blog/2009/09/the-story-behind-the-atlantic-salmon/">dead salmon</a>.</p>
<p>&nbsp;</p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/Bildschirmfoto-2012-09-05-um-11.30.54.png"><img class="alignright size-thumbnail wp-image-152" title="fMri" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/Bildschirmfoto-2012-09-05-um-11.30.54-150x150.png" alt="" width="150" height="150" /></a></p>
<h2>The power of brain images for everybody</h2>
<p>What are the consequence of these troubling findings? The answer is clear. <span style="text-decoration: underline;">Everybody</span> should be equipped with these powerful tools of research communication! We at <em>IRET</em> made it to our mission to provide the latest, cutting-edge tools for your research analysis. In this case we adopted a new technology called &#8220;visually weighted regression&#8221; or &#8220;watercolor plots&#8221; (see <a href="http://www.fight-entropy.com/2012/07/visually-weighted-regression.html">here</a>, <a title="Visually weighted regression in R (à la Solomon Hsiang)" href="http://www.nicebread.de/visually-weighted-regression-in-r-a-la-solomon-hsiang/">here</a>, or <a href="http://andrewgelman.com/2012/08/graphs-showing-regression-uncertainty-the-code/">here</a>), and simply applied a new color scheme.</p>
<p>But now, let&#8217;s get some hands on it!</p>
<h2>The example</h2>
<p>Imagine you invested a lot of effort in collecting the data of 41 participants. Now you find following pattern in 2 of your 87 variables:</p>
<p><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/Bildschirmfoto-2012-09-05-um-11.16.06.png"><img class="aligncenter size-medium wp-image-146" title="Bildschirmfoto 2012-09-05 um 11.16.06" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/Bildschirmfoto-2012-09-05-um-11.16.06-300x292.png" alt="" width="300" height="292" /></a></p>
<p>You could show that plain scatterplot. But should you do it? Nay. Of course everybody would spot the outliers on the top right. But which is much more important: it is <em>b-o-r-i-n-g</em>!</p>
<p>What is the alternative? Reporting the correlation as text? &#8220;We found a correlation of <em>r</em> = .38 (<em>p</em> = .014)&#8221;. Yawn.</p>
<p>Or maybe: &#8220;We chose to use a correlation technique that is robust against outliers and violations of normality, the Spearman rank coefficient. It turned out that the correlation broke down and was not significant any more (<em>r</em> = .06, <em>p</em> = .708).&#8221;.</p>
<p>Don&#8217;t be silly! With that style of scientific reporting, there would be nothing to write home about. But you can be sure: we have the right tools for you. Finally, the power of pictures is not limited to brain research &#8211; now you can turn any data into a magical fMRI plot like that:</p>
<p style="text-align: center;"><a href="http://www.nicebread.de/WP/wp-content/uploads/2012/09/Bildschirmfoto-2012-09-05-um-11.26.02.png"><img class="aligncenter  wp-image-149" title="Bildschirmfoto 2012-09-05 um 11.26.02" src="http://www.nicebread.de/WP/wp-content/uploads/2012/09/Bildschirmfoto-2012-09-05-um-11.26.02.png" alt="" width="546" height="550" /></a></p>
<p>Isn&#8217;t that beautiful? We recommend to accompany the figure with an elaborated description: &#8220;For local fitting, we used spline smoothers from 10`000 bootstrap replications. For a robust estimation of vertical confidence densities, a re-descending M-estimator with Tukey&#8217;s biweight function was employed. As one can clearly see in the plot, there is  significant confidence in the prediction of the x=0, y=0 region, as well as a minor hot spot in the x=15, y=60 region (also known as the <em>supra-dextral data region</em>).&#8221;</p>
<h2>Magical Data Enhancer Tool</h2>
<p>With the Magical Data Enhancer Tool (MDET) you can &#8230;</p>
<ul>
<li>… turn boring, marginally significant, or just crappy results into a stunning research experience</li>
<li>… publish in scientific journal with higher impact factors</li>
<li>… receive the media coverage that you and your research deserve</li>
<li>… achieve higher acceptance rates from funding agencies</li>
<li>… impress young women at the bar (you wouldn&#8217;t show a plain scatterplot, dude?!)</li>
</ul>
<h2>FAQ</h2>
<p>Q: But &#8211; isn&#8217;t that approach unethical?<br />
A: No, it&#8217;s not at all. In contrast, we at IRES think that it is unethical that only some researchers are allowed to exploit the cognitive biases of their readers. We design our products with a great respect for humanity and we believe that every researcher who can afford our products should have the same powerful tools at hand.</p>
<p>Q: How much does you product cost?<br />
A: The standard version of the <em>Magical Data Enhancer</em> ships for 12&#8217;998 $. We are aware that this is a significant investment. But, come on: You deserve it! Furthermore, we will soon publish a free trial version, including the full R code on this blog. So stay tuned!</p>
<p>&nbsp;</p>
<p>Best regards,</p>
<p>Lexis &#8220;Lex&#8221; Brycenet (CEO &amp; CTO Research Communication)<em><br />
International Research Enhancement Technology (IRET)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicebread.de/amazing-fmri-plots-for-everybody/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
