Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Quarto GHA Workflow Runner committed Sep 9, 2024
1 parent d7db0cc commit f224e85
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
66339ad3
905f3538
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ <h3 class="anchored" data-anchor-id="tutorial">Tutorial</h3>
<li><a href="./tutorial_pages/seed.html">Setting the seed</a> – How can you generate the same random numbers?</li>
<li><a href="./tutorial_pages/sample-size-n.html">Sample size <code>n</code></a> – How many values should you generate within a simulation?</li>
<li><a href="./tutorial_pages/number-of-simulations-nrep.html">Number of simulations <code>nrep</code></a> – How many repeats of a simulation should you run?</li>
<li><a href="./tutorial_pages/dry-rule.html">Dry rule</a> – How to write your own functions?</li>
<li><a href="./tutorial_pages/dry-rule.html">DRY rule</a> – How to write your own functions?</li>
<li><a href="./tutorial_pages/check-alpha.html">Simulate to check alpha</a> – Write your first simulation and check the rate of false-positive findings.<br>
</li>
<li><a href="./tutorial_pages/check-power.html">Simulate to check power</a> – Simulate data to perform a power analysis.<br>
Expand Down
14 changes: 7 additions & 7 deletions search.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,74 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/simulate-for-preregistration.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/sample-size-n.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/repeat.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/random-numbers-generators.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/number-of-simulations-nrep.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/general-structure.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/download-repo.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/check-power.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/basic-principles.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/index.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.736Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/check-alpha.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/definition.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/dry-rule.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/limitations.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/purpose.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/real-life-example.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/resources.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
<url>
<loc>https://lmu-osc.github.io/Introduction-Simulations-in-R/tutorial_pages/seed.html</loc>
<lastmod>2024-09-08T09:03:58.202Z</lastmod>
<lastmod>2024-09-09T00:45:59.740Z</lastmod>
</url>
</urlset>
8 changes: 5 additions & 3 deletions tutorial_pages/check-alpha.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,11 @@ <h1>Using simulations to check alpha</h1>
<p>In both cases, we expect 50 out of the 1000 tests to be significant by chance (i.e.&nbsp;with a <em>p</em>-value under 0.05). In my simulations, I get 40 and 45 false positive results, for <code>n = 10</code> and <code>n = 100</code>, respectively. How many did you get?</p>
<p>These proportions are not significantly different from 5%.</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">prop.test</span>(<span class="dv">45</span>, <span class="dv">1000</span>, <span class="at">p =</span> <span class="fl">0.05</span>, <span class="at">alternative =</span> <span class="st">"two.sided"</span>, <span class="at">correct =</span> <span class="cn">TRUE</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="line-block">&nbsp;1-sample proportions test with continuity correction<br>
&nbsp;data: 45 out of 1000, null probability 0.05<br>
&nbsp;X-squared = 0.42632, df = 1, p-value = 0.5138</div>
<blockquote class="blockquote">
<p>1-sample proportions test with continuity correction<br>
data: 45 out of 1000, null probability 0.05<br>
X-squared = 0.42632, df = 1, p-value = 0.5138</p>
</blockquote>
<p>It is important to note that, although <code>alpha = 0.05</code> is commonly used, this is an arbitrary choice and you should consider what is an appropriate type 1 error rate for your particular investigation.</p>
<p>Although it isn’t necessary to check that a statistical analysis as simple as a <em>t</em>-test does not yield more than 5% false-positive results, in situations where the structure of the data is complex and analysed with more advanced models (e.g.&nbsp;when explanatory variables are mathematically linked to each other or are combined in a mixed-effect model), this may allow to compare different modelling approaches and select one that does not produce more than 5% false-positive results.</p>
<p>Such complex example, where simulation is the only viable approach to construct a statistical model that does not lead to spurious effects, can be found in this paper:</p>
Expand Down
10 changes: 1 addition & 9 deletions tutorial_pages/check-power.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,7 @@ <h1>Checking power through simulations</h1>
<p>If we sample values from two normal distributions with different means (e.g.&nbsp;N(0,1) and N(0.5,1)), what is the minimum sample size we need to detect a significant difference in means with a <em>t</em>-test 80% of the time?</p>
<hr>
<p><strong>YOUR TURN:</strong><br>
1. Use your simulation skills to work out the power through simulation. Write a function that does the following:</p>
<ol type="i">
<li>Draws <code>n</code> values from a random normal distribution with <code>mean1</code> and another <code>n</code> values from a normal distribution with <code>mean2</code>.</li>
<li>Compares the means of these two samples with a <em>t</em>-test and extracts the <em>p</em>-value.</li>
</ol>
<ol start="2" type="1">
<li>Replicate the function 1000 times using the parameters used in the power calculation above (that used the <code>power.t.test()</code> function).</li>
<li>Calculate the proportion of <em>p</em>-values that are smaller than 0.05.</li>
</ol>
1. Use your simulation skills to work out the power through simulation. Write a function that does the following: i) Draws <code>n</code> values from a random normal distribution with <code>mean1</code> and another <code>n</code> values from a normal distribution with <code>mean2</code>. ii) Compares the means of these two samples with a <em>t</em>-test and extracts the <em>p</em>-value. 2. Replicate the function 1000 times using the parameters used in the power calculation above (that used the <code>power.t.test()</code> function). 3. Calculate the proportion of <em>p</em>-values that are smaller than 0.05.</p>
<hr>
<p><strong><em>p</em>-values of <em>t</em>-tests comparing means from 1000 simulations of N(0,1) and N(0.5,1) with n = 64:</strong></p>
<p><br> <img src="../assets/hist-power.png" width="500"><br>
Expand Down
2 changes: 1 addition & 1 deletion tutorial_pages/dry-rule.html
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ <h2 id="toc-title">On this page</h2>
<h1><strong>D</strong>o not <strong>R</strong>epeat <strong>Y</strong>ourself – DRY rule</h1>
<section id="vs.-write-everything-twice-wet-rule" class="level2">
<h2 class="anchored" data-anchor-id="vs.-write-everything-twice-wet-rule"><em>vs.</em> <strong>W</strong>rite <strong>E</strong>verything <strong>T</strong>wice – WET rule</h2>
<p><br> Following the WET rule:</p>
<p>Following the WET rule:</p>
<ul>
<li>Makes changes more difficult and/or time consuming.<br>
</li>
Expand Down
2 changes: 1 addition & 1 deletion tutorial_pages/random-numbers-generators.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ <h1>Random number generators</h1>
<p>Sampling without replacement means that when you repeatedly draw e.g.&nbsp;one item at a time from a pool of items, any item selected during the first draw is not available for selection during the second draw, and the first and second selected items are not in the pool to select from during the third draw, etc. Sampling with replacement means that all the original options are available at each draw.</p>
<hr>
<p><strong>YOUR TURN:</strong><br>
Sample 100 values between 3 and 103 with replacement. For this, open the file <code>./exercise_script.R</code> from the root of your local repository (with or without answers), review the examples if needed, complete the exercise, and check out the proposed answer.</p>
Sample 100 values between 3 and 103 with replacement. For this, open the R script(s) with the exercises (<code>./exercise_script_with_solutions.R</code> and/or <code>./exercise_script_without_solutions.R</code>) from the root of your local repository, review the examples if needed, complete the exercise, and check out the proposed answer.</p>
<hr>
<p>The following functions draw <code>n</code> values from distributions with the specified parameters:</p>
<ul>
Expand Down
1 change: 0 additions & 1 deletion tutorial_pages/real-life-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ <h1>Real-life example</h1>
</ul>
<p>I created this code while preparing my preregistration for a simple behavioural ecology experiment about methods for independently manipulating palatability and colour in small insect prey (<a href="https://doi.org/10.1371/journal.pone.0231205">article</a>, <a href="https://osf.io/f8uk9?view_only=3943e7bb9c5f4effbf119ca5b062fe80">OSF preregistration</a>).</p>
<p>The R script screenshot below, <code>glm_Freq_vs_YN.R</code>, can be found in the folder <a href="https://github.com/lmu-osc/Introduction-Simulations-in-R/tree/main/Ihle2020">Ihle2020</a>.</p>
<p><br></p>
<p>This walkthrough will use the steps as defined on the page ‘<a href="../tutorial_pages/general-structure.html">General structure</a>’.</p>
<ol type="1">
<li><p><strong>Define sample sizes</strong> (within a dataset and number of replicates), <strong>experimental design</strong> (fixed dataset structure, e.g.&nbsp;treatment groups, factors), and <strong>parameters</strong> that will need to vary (here, the strength of the effect).</p>
Expand Down
5 changes: 1 addition & 4 deletions tutorial_pages/repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,7 @@ <h2 id="toc-title">On this page</h2>

<section id="repetition" class="level1">
<h1>Repetition</h1>
<p>The function</p>
<ul>
<li><code>replicate(nrep, expression)</code> repeats the <code>expression</code> provided <code>nrep</code> times.</li>
</ul>
<p>The function <code>replicate(nrep, expression)</code> repeats the <code>expression</code> provided <code>nrep</code> times.</p>
<p>For example, <code>replicate(10, mean(rnorm(100)))</code> reads: ‘Draw 100 values from a normal distribution with a mean of 0 and a standard deviation of 1 (the default values of <code>rnorm(n, mean, sd)</code>), calculate the mean of these 100 values, and do all that 10 times.’</p>
<hr>
<p><strong>YOUR TURN:</strong><br>
Expand Down

0 comments on commit f224e85

Please sign in to comment.