<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/extracting-a-reference-grid-of-your-data-for-machine-learning-models-visualization/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://neuropsychology.github.io/psycho.R//2018/06/25/refdata.html"> Dominique Makowski</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Sometimes, for visualization purposes, we want to extract a reference grid of our dataset. This reference grid often contains equally spaced values of a “target” variable, and all other variables “fixed” by their mean, median or reference level. The <code>refdata</code> of the <a rel="nofollow" href="https://github.com/neuropsychology/psycho.R" target="_blank"><code>psycho</code> package</a> was built to do just that.</p>
<h1>The Model</h1>
<p>Let’s build a complex machine learning model (a neural network) predicting the Sex (the probability of being a man, as women are here the reference level) of our participants with all the variables of the dataframe.</p>
<div>
<div>
<pre><code><span># devtools::install_github(&quot;neuropsychology/psycho.R&quot;) # Install the latest psycho version if needed</span><span>
</span><span># Load packages</span><span>
</span><span>library</span><span>(</span><span>tidyverse</span><span>)</span><span>
</span><span>library</span><span>(</span><span>caret</span><span>)</span><span>
</span><span>library</span><span>(</span><span>psycho</span><span>)</span><span>
</span><span># Import data</span><span>
</span><span>df</span><span> </span><span>&lt;-</span><span> </span><span>psycho</span><span>::</span><span>affective</span><span> </span><span>%>%</span><span> </span><span>standardize</span><span>()</span><span> </span><span>%>%</span><span> </span><span># Standardize</span><span>
</span><span>na.omit</span><span>(</span><span>df</span><span>)</span><span> </span><span># Remove missing values</span><span>
</span><span># Fit the model</span><span>
</span><span>model</span><span> </span><span>&lt;-</span><span> </span><span>caret</span><span>::</span><span>train</span><span>(</span><span>Sex</span><span> </span><span>~</span><span> </span><span>.</span><span>,</span><span>
</span><span>data</span><span>=</span><span>df</span><span>,</span><span>
</span><span>method</span><span> </span><span>=</span><span> </span><span>&quot;nnet&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code><span>varImp</span><span>(</span><span>model</span><span>,</span><span> </span><span>scale</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code>## nnet variable importance
## 
##                    Overall
## Salary2000+        100.000
## Concealing          48.761
## Adjusting           46.198
## Birth_SeasonSpring  39.289
## Life_Satisfaction   22.567
## Salary&lt;2000          9.176
## Birth_SeasonSummer   8.863
## Birth_SeasonWinter   6.624
## Tolerating           5.686
## Age                  0.000
</code></pre>
</div>
</div>
<p>It seems that the upper salary category (<em>> 2000€ / month</em>) is the most important variable of the model, followed by the concealing and adjusting personality traits. Interesting, but what does it say about the actual relationship between those variables and our outcome?</p>
<h1>Simple</h1>
<p>To visualize the effect of Salary, we can extract a reference data with all the salary levels and all other variables fixed at their mean level.</p>
<div>
<div>
<pre><code><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span> </span><span>%>%</span><span> </span><span>select</span><span>(</span><span>-</span><span>Sex</span><span>)</span><span> </span><span>%>%</span><span> </span><span># We remove the sex as it is our variable &quot;to predict&quot;</span><span>
</span><span>refdata</span><span>(</span><span>&quot;Salary&quot;</span><span>)</span><span>
</span><span>newdata</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>newdata</span><span>,</span><span> </span><span>digits</span><span>=</span><span>2</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<table>
<thead>
<tr>
<th>Salary</th>
<th>Age</th>
<th>Birth_Season</th>
<th>Life_Satisfaction</th>
<th>Concealing</th>
<th>Adjusting</th>
<th>Tolerating</th>
</tr>
</thead>
<tbody>
<tr>
<td>&lt;1000</td>
<td>0.11</td>
<td>Fall</td>
<td>-0.01</td>
<td>0</td>
<td>0.03</td>
<td>-0.02</td>
</tr>
<tr>
<td>&lt;2000</td>
<td>0.11</td>
<td>Fall</td>
<td>-0.01</td>
<td>0</td>
<td>0.03</td>
<td>-0.02</td>
</tr>
<tr>
<td>2000+</td>
<td>0.11</td>
<td>Fall</td>
<td>-0.01</td>
<td>0</td>
<td>0.03</td>
<td>-0.02</td>
</tr>
</tbody>
</table>
<p>We can make predictions from the model on this minimal dataset and visualize it.</p>
<div>
<div>
<pre><code><span>predicted</span><span> </span><span>&lt;-</span><span> </span><span>predict</span><span>(</span><span>model</span><span>,</span><span> </span><span>newdata</span><span>,</span><span> </span><span>type</span><span> </span><span>=</span><span> </span><span>&quot;prob&quot;</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>cbind</span><span>(</span><span>newdata</span><span>,</span><span> </span><span>predicted</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Salary</span><span>,</span><span> </span><span>y</span><span>=</span><span>M</span><span>,</span><span> </span><span>group</span><span>=</span><span>1</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>()</span><span> </span><span>+</span><span>
</span><span>theme_classic</span><span>()</span><span> </span><span>+</span><span>
</span><span>ylab</span><span>(</span><span>&quot;Probability of being a man&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img src="https://i2.wp.com/raw.githubusercontent.com/neuropsychology/psycho.R/master/docs/_posts/2018-06-25-refdata_files/figure-markdown_github/unnamed-chunk-6-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>Well, it seems that males are more represented in categories with lower and uppper salary classes (that least, that’s what the model learnt).</p>
<h1>Multiple Targets</h1>
<p>How does this interact with the concealing personality trait?</p>
<div>
<div>
<pre><code><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span> </span><span>%>%</span><span> </span><span>select</span><span>(</span><span>-</span><span>Sex</span><span>)</span><span> </span><span>%>%</span><span> </span><span>refdata</span><span>(</span><span>c</span><span>(</span><span>&quot;Salary&quot;</span><span>,</span><span> </span><span>&quot;Concealing&quot;</span><span>))</span><span> </span><span># We can sepcify multiple targets</span><span>
</span><span>newdata</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>head</span><span>(</span><span>newdata</span><span>,</span><span> </span><span>5</span><span>),</span><span> </span><span>digits</span><span>=</span><span>2</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<table>
<thead>
<tr>
<th>Salary</th>
<th>Concealing</th>
<th>Age</th>
<th>Birth_Season</th>
<th>Life_Satisfaction</th>
<th>Adjusting</th>
<th>Tolerating</th>
</tr>
</thead>
<tbody>
<tr>
<td>&lt;1000</td>
<td>-2.52</td>
<td>0.11</td>
<td>Fall</td>
<td>-0.01</td>
<td>0.03</td>
<td>-0.02</td>
</tr>
<tr>
<td>&lt;2000</td>
<td>-2.52</td>
<td>0.11</td>
<td>Fall</td>
<td>-0.01</td>
<td>0.03</td>
<td>-0.02</td>
</tr>
<tr>
<td>2000+</td>
<td>-2.52</td>
<td>0.11</td>
<td>Fall</td>
<td>-0.01</td>
<td>0.03</td>
<td>-0.02</td>
</tr>
<tr>
<td>&lt;1000</td>
<td>-1.99</td>
<td>0.11</td>
<td>Fall</td>
<td>-0.01</td>
<td>0.03</td>
<td>-0.02</td>
</tr>
<tr>
<td>&lt;2000</td>
<td>-1.99</td>
<td>0.11</td>
<td>Fall</td>
<td>-0.01</td>
<td>0.03</td>
<td>-0.02</td>
</tr>
</tbody>
</table>
<p>This created 10 evenly spread values of Concealing (from min to max) and “merged” them with all the levels of Salary.</p>
<div>
<div>
<pre><code><span>predicted</span><span> </span><span>&lt;-</span><span> </span><span>predict</span><span>(</span><span>model</span><span>,</span><span> </span><span>newdata</span><span>,</span><span> </span><span>type</span><span> </span><span>=</span><span> </span><span>&quot;prob&quot;</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>cbind</span><span>(</span><span>newdata</span><span>,</span><span> </span><span>predicted</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Concealing</span><span>,</span><span> </span><span>y</span><span>=</span><span>M</span><span>,</span><span> </span><span>colour</span><span>=</span><span>Salary</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>()</span><span> </span><span>+</span><span>
</span><span>theme_classic</span><span>()</span><span> </span><span>+</span><span>
</span><span>ylab</span><span>(</span><span>&quot;Probability of being a man&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img src="https://i0.wp.com/raw.githubusercontent.com/neuropsychology/psycho.R/master/docs/_posts/2018-06-25-refdata_files/figure-markdown_github/unnamed-chunk-9-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>This plot is rather ugly…</p>
<h1>Increase Length</h1>
<div>
<div>
<pre><code><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span> </span><span>%>%</span><span> </span><span>select</span><span>(</span><span>-</span><span>Sex</span><span>)</span><span> </span><span>%>%</span><span> </span><span>refdata</span><span>(</span><span>c</span><span>(</span><span>&quot;Salary&quot;</span><span>,</span><span> </span><span>&quot;Concealing&quot;</span><span>),</span><span> </span><span>length.out</span><span>=</span><span>500</span><span>)</span><span> </span><span># Set the length by which to spread numeric targets</span><span>
</span><span>predicted</span><span> </span><span>&lt;-</span><span> </span><span>predict</span><span>(</span><span>model</span><span>,</span><span> </span><span>newdata</span><span>,</span><span> </span><span>type</span><span> </span><span>=</span><span> </span><span>&quot;prob&quot;</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>cbind</span><span>(</span><span>newdata</span><span>,</span><span> </span><span>predicted</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Concealing</span><span>,</span><span> </span><span>y</span><span>=</span><span>M</span><span>,</span><span> </span><span>colour</span><span>=</span><span>Salary</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>(</span><span>size</span><span>=</span><span>1</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme_classic</span><span>()</span><span> </span><span>+</span><span>
</span><span>ylab</span><span>(</span><span>&quot;Probability of being a man&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img src="https://i1.wp.com/raw.githubusercontent.com/neuropsychology/psycho.R/master/docs/_posts/2018-06-25-refdata_files/figure-markdown_github/unnamed-chunk-10-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>It seems that for richer people, the concealing treshold for increasing the probability of being a male is lower.</p>
<h1>How to Fix (Maintain) Numeric Variables?</h1>
<p>For now, all other variables were fixed to their mean level. But maybe their behaviour would be different when other variables are low or high.</p>
<div>
<div>
<pre><code><span>newdata_min</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span> </span><span>%>%</span><span> </span><span>select</span><span>(</span><span>-</span><span>Sex</span><span>)</span><span> </span><span>%>%</span><span> </span><span>refdata</span><span>(</span><span>c</span><span>(</span><span>&quot;Salary&quot;</span><span>,</span><span> </span><span>&quot;Concealing&quot;</span><span>),</span><span> </span><span>length.out</span><span>=</span><span>500</span><span>,</span><span> </span><span>numerics</span><span> </span><span>=</span><span> </span><span>&quot;min&quot;</span><span>)</span><span> </span><span>%>%</span><span> </span><span># Set the other numeric variables to their minimum </span><span>
</span><span>mutate</span><span>(</span><span>Fixed</span><span> </span><span>=</span><span> </span><span>&quot;Minimum&quot;</span><span>)</span><span>
</span><span>newdata_max</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span> </span><span>%>%</span><span> </span><span>select</span><span>(</span><span>-</span><span>Sex</span><span>)</span><span> </span><span>%>%</span><span> </span><span>refdata</span><span>(</span><span>c</span><span>(</span><span>&quot;Salary&quot;</span><span>,</span><span> </span><span>&quot;Concealing&quot;</span><span>),</span><span> </span><span>length.out</span><span>=</span><span>500</span><span>,</span><span> </span><span>numerics</span><span> </span><span>=</span><span> </span><span>&quot;max&quot;</span><span>)</span><span>%>%</span><span> </span><span># Set the other numeric variables to their maximum </span><span>
</span><span>mutate</span><span>(</span><span>Fixed</span><span> </span><span>=</span><span> </span><span>&quot;Maximum&quot;</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>rbind</span><span>(</span><span>newdata_min</span><span>,</span><span> </span><span>newdata_max</span><span>)</span><span>
</span><span>predicted</span><span> </span><span>&lt;-</span><span> </span><span>predict</span><span>(</span><span>model</span><span>,</span><span> </span><span>newdata</span><span>,</span><span> </span><span>type</span><span> </span><span>=</span><span> </span><span>&quot;prob&quot;</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>cbind</span><span>(</span><span>newdata</span><span>,</span><span> </span><span>predicted</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Concealing</span><span>,</span><span> </span><span>y</span><span>=</span><span>M</span><span>,</span><span> </span><span>colour</span><span>=</span><span>Salary</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>(</span><span>size</span><span>=</span><span>1</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme_classic</span><span>()</span><span> </span><span>+</span><span>
</span><span>ylab</span><span>(</span><span>&quot;Probability of being a man&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>facet_wrap</span><span>(</span><span>~</span><span>Fixed</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img src="https://i2.wp.com/raw.githubusercontent.com/neuropsychology/psycho.R/master/docs/_posts/2018-06-25-refdata_files/figure-markdown_github/unnamed-chunk-11-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>When all variables are high, concealing is not related to the sex for richer people. When the variables are set to their minimum, the concealing treshold for the two lower salary classes is higher (around 1.5).</p>
<h1>Chains of refdata</h1>
<p>Let’s say we want one target of length 500 and another to length 10 To do it, we can nicely chain <code>refdata</code>.</p>
<div>
<div>
<pre><code><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span> </span><span>%>%</span><span> </span><span>select</span><span>(</span><span>-</span><span>Sex</span><span>)</span><span> </span><span>%>%</span><span> </span><span>refdata</span><span>(</span><span>c</span><span>(</span><span>&quot;Adjusting&quot;</span><span>,</span><span> </span><span>&quot;Concealing&quot;</span><span>),</span><span> </span><span>length.out</span><span>=</span><span>500</span><span>)</span><span> </span><span>%>%</span><span> </span><span>refdata</span><span>(</span><span>&quot;Adjusting&quot;</span><span>,</span><span> </span><span>length.out</span><span>=</span><span>10</span><span>,</span><span> </span><span>numerics</span><span> </span><span>=</span><span> </span><span>&quot;combination&quot;</span><span>)</span><span>
</span><span>predicted</span><span> </span><span>&lt;-</span><span> </span><span>predict</span><span>(</span><span>model</span><span>,</span><span> </span><span>newdata</span><span>,</span><span> </span><span>type</span><span> </span><span>=</span><span> </span><span>&quot;prob&quot;</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>cbind</span><span>(</span><span>newdata</span><span>,</span><span> </span><span>predicted</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>Adjusting</span><span>=</span><span>as.factor</span><span>(</span><span>round</span><span>(</span><span>Adjusting</span><span>,</span><span> </span><span>2</span><span>)))</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Concealing</span><span>,</span><span> </span><span>y</span><span>=</span><span>M</span><span>,</span><span> </span><span>alpha</span><span>=</span><span>Adjusting</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_line</span><span>(</span><span>size</span><span>=</span><span>1</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme_classic</span><span>()</span><span> </span><span>+</span><span>
</span><span>ylab</span><span>(</span><span>&quot;Probability of being a man&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img src="https://i1.wp.com/raw.githubusercontent.com/neuropsychology/psycho.R/master/docs/_posts/2018-06-25-refdata_files/figure-markdown_github/unnamed-chunk-12-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>The concealing treshold highly depends on adjusting. The more adjusting is high (dark lines), the less concealing is needed to increase the probability of being a man.</p>
<h1>Combinations of Observed Values</h1>
<p>Let’s observe the link with Adjusting by generating a reference grid with all combinations of factors (salary, birth month etc.), and fixing numerics to their median (we could also chose “combinations” but it would generate a very, very very big dataframe with all possible combinations of values).</p>
<div>
<div>
<pre><code><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span> </span><span>%>%</span><span> </span><span>select</span><span>(</span><span>-</span><span>Sex</span><span>)</span><span> </span><span>%>%</span><span> </span><span>refdata</span><span>(</span><span>&quot;Adjusting&quot;</span><span>,</span><span> </span><span>length.out</span><span>=</span><span>10</span><span>,</span><span> </span><span>factors</span><span> </span><span>=</span><span> </span><span>&quot;combination&quot;</span><span>,</span><span> </span><span>numerics</span><span> </span><span>=</span><span> </span><span>&quot;median&quot;</span><span>)</span><span> </span><span>predicted</span><span> </span><span>&lt;-</span><span> </span><span>predict</span><span>(</span><span>model</span><span>,</span><span> </span><span>newdata</span><span>,</span><span> </span><span>type</span><span> </span><span>=</span><span> </span><span>&quot;prob&quot;</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>cbind</span><span>(</span><span>newdata</span><span>,</span><span> </span><span>predicted</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Adjusting</span><span>,</span><span> </span><span>y</span><span>=</span><span>M</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_jitter</span><span>(</span><span>size</span><span>=</span><span>1</span><span>,</span><span> </span><span>width</span><span>=</span><span>0</span><span>,</span><span> </span><span>height</span><span> </span><span>=</span><span> </span><span>0.01</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_smooth</span><span>(</span><span>size</span><span>=</span><span>1</span><span>,</span><span> </span><span>se</span><span>=</span><span>FALSE</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme_classic</span><span>()</span><span> </span><span>+</span><span>
</span><span>ylab</span><span>(</span><span>&quot;Probability of being a man&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img src="https://i1.wp.com/raw.githubusercontent.com/neuropsychology/psycho.R/master/docs/_posts/2018-06-25-refdata_files/figure-markdown_github/unnamed-chunk-13-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>The more adjusting is high, the more probability there is to be a man. <strong>But let’s generate now much more observations</strong>.</p>
<div>
<div>
<pre><code><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span> </span><span>%>%</span><span> </span><span>select</span><span>(</span><span>-</span><span>Sex</span><span>)</span><span> </span><span>%>%</span><span> </span><span>refdata</span><span>(</span><span>&quot;Adjusting&quot;</span><span>,</span><span> </span><span>length.out</span><span>=</span><span>10000</span><span>,</span><span> </span><span>factors</span><span> </span><span>=</span><span> </span><span>&quot;combination&quot;</span><span>,</span><span> </span><span>numerics</span><span> </span><span>=</span><span> </span><span>&quot;median&quot;</span><span>)</span><span> </span><span>predicted</span><span> </span><span>&lt;-</span><span> </span><span>predict</span><span>(</span><span>model</span><span>,</span><span> </span><span>newdata</span><span>,</span><span> </span><span>type</span><span> </span><span>=</span><span> </span><span>&quot;prob&quot;</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>&lt;-</span><span> </span><span>cbind</span><span>(</span><span>newdata</span><span>,</span><span> </span><span>predicted</span><span>)</span><span>
</span><span>newdata</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Adjusting</span><span>,</span><span> </span><span>y</span><span>=</span><span>M</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_jitter</span><span>(</span><span>size</span><span>=</span><span>1</span><span>,</span><span> </span><span>width</span><span>=</span><span>0</span><span>,</span><span> </span><span>height</span><span> </span><span>=</span><span> </span><span>0.01</span><span>,</span><span> </span><span>alpha</span><span>=</span><span>0.2</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_smooth</span><span>(</span><span>size</span><span>=</span><span>1</span><span>,</span><span> </span><span>se</span><span>=</span><span>FALSE</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme_classic</span><span>()</span><span> </span><span>+</span><span>
</span><span>ylab</span><span>(</span><span>&quot;Probability of being a man&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img src="https://i0.wp.com/raw.githubusercontent.com/neuropsychology/psycho.R/master/docs/_posts/2018-06-25-refdata_files/figure-markdown_github/unnamed-chunk-14-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>We can still see, “behind the scenes”, how different factors influence this relationship.</p>
<h1>Credits</h1>
<p>This package helped you? Don’t forget to cite the various packages you used <img alt="🙂" src="https://s.w.org/images/core/emoji/2.4/72x72/1f642.png" class="wp-smiley"></p>
<p>You can cite <code>psycho</code> as follows:</p>
<ul>
<li>Makowski, (2018). <em>The psycho Package: An Efficient and Publishing-Oriented Workflow for Psychological Science</em>. Journal of Open Source Software, 3(22), 470. <a rel="nofollow" href="https://doi.org/10.21105/joss.00470" target="_blank">https://doi.org/10.21105/joss.00470</a></li>
</ul>
<h1>Contribute</h1>
<p><strong>psycho</strong> is a young package and still need some love. Therefore, if you have any advices, opinions or such, we encourage you to either let us know by opening an <a rel="nofollow" href="https://github.com/neuropsychology/psycho.R/issues" target="_blank">issue</a>, or even better, try to implement them yourself by <a rel="nofollow" href="https://github.com/neuropsychology/psycho.R/blob/master/.github/CONTRIBUTING.md" target="_blank">contributing</a> to the code.</p>
<h1>Previous blogposts</h1>
<ul>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/06/19/analyze_ttest.html" target="_blank">Copy/paste t-tests Directly to Manuscripts</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/06/11/bayesian_correlation.html" target="_blank">APA Formatted Bayesian Correlation</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/06/03/plot_bayesian_model.html" target="_blank">Fancy Plot (with Posterior Samples) for Bayesian Regressions</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/05/24/n_factors.html" target="_blank">How Many Factors to Retain in Factor Analysis</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/05/20/correlation.html" target="_blank">Beautiful and Powerful Correlation Tables</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/05/10/interpret_mixed_models.html" target="_blank">Format and Interpret Linear Mixed Models</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/05/01/repeated_measure_anovas.html" target="_blank">How to do Repeated Measures ANOVAs</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/03/29/standardize.html" target="_blank">Standardize (Z-score) a dataframe</a></li>
<li><a rel="nofollow" href="https://neuropsychology.github.io/psycho.R/2018/03/29/SDT.html" target="_blank">Compute Signal Detection Theory Indices</a></li>
</ul>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://neuropsychology.github.io/psycho.R//2018/06/25/refdata.html"> Dominique Makowski</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/mNsn_nS5FOo" height="1"></a></div>