Skip to content

Commit

Permalink
update intro and added url to videos
Browse files Browse the repository at this point in the history
  • Loading branch information
hcp4715 committed Dec 20, 2024
1 parent 5c613fa commit f27ea71
Show file tree
Hide file tree
Showing 28 changed files with 166 additions and 160 deletions.
Binary file modified Book/_book/_main_files/figure-html/unnamed-chunk-255-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Book/_book/_main_files/figure-html/unnamed-chunk-275-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Book/_book/_main_files/figure-html/unnamed-chunk-277-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Book/_book/_main_files/figure-html/unnamed-chunk-278-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Book/_book/_main_files/figure-html/unnamed-chunk-288-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Book/_book/_main_files/figure-html/unnamed-chunk-289-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions Book/_book/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -565,27 +565,30 @@ <h1>
<div id="header">
<h1 class="title">R语言在心理学研究中的应用: 从原始数据到可重复的论文手稿(V2)</h1>
<p class="author"><em>胡传鹏(等)</em></p>
<p class="date"><em>2024年09月22日</em></p>
<p class="date"><em>2024年12月20日</em></p>
</div>
<div id="引言" class="section level1 unnumbered hasAnchor">
<h1>引言<a href="index.html#引言" class="anchor-section" aria-label="Anchor link to header"></a></h1>
<p>本电子书通过<a href="https://bookdown.org/"><code>bookdown</code></a>进行创建,相关代码见<a href="https://github.com/hcp4715/R4PsyBook">这里</a>。由于文字稿来自于对课堂录音的整理,完全由本人与志愿者以志愿方式进行整理,因此,可能存在如下问题:</p>
<p>本电子书通过<a href="https://bookdown.org/"><code>bookdown</code></a>进行创建。文字与代码是对本人2024年春季学期的《R语言在心理研究中应用》一课录音的整理而。文字稿由本人与志愿者以志愿方式进行整理,因此,可能存在如下问题:</p>
<ul>
<li>文字口语化严重</li>
<li>图片或者文献引用不全</li>
<li>错别字等</li>
<li>代码错误</li>
</ul>
<p>望读者朋友多多包涵。欢迎有兴趣有能力的朋友多多批评指正。<br />
指出问题的方式:在本电子书的GitHub仓库的<a href="https://github.com/hcp4715/R4PsyBook/issues">issues</a>中开新的issue。<br />
<p>望读者朋友多多包涵。欢迎有兴趣有能力的朋友多多批评指正。如果您觉得这个电子书有用,可以给我们的github repo加一个🌟,这是对我们持续开源的巨大鼓励!<br />
</p>
<p>本课相关资源也完全开源,链接如下:<a href="https://github.com/hcp4715/R4Psy">课件</a><a href="https://space.bilibili.com/252509184/channel/collectiondetail?sid=2314135">B站录频</a><a href="https://github.com/hcp4715/R4PsyBook">本电子书代码</a><br />
</p>
<p>本套课程及资源会在每年春季学期更新,欢迎大家多多批评指正。提出问题的最佳方式:在本电子书的GitHub仓库的<a href="https://github.com/hcp4715/R4PsyBook/issues">issues</a>中开新的issue。<br />
参与贡献方式:见下面《如何帮助完善本书》这一小节。</p>
<div id="开放电子书的初衷" class="section level2 hasAnchor" number="0.1">
<h2><span class="header-section-number">0.1</span> 开放电子书的初衷<a href="index.html#开放电子书的初衷" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>分享知识,向众多开源的电子书作者致敬,为中文网络世界中的R语言相关教材略尽绵薄之力。</p>
</div>
<div id="如何帮助完善本书" class="section level2 hasAnchor" number="0.2">
<h2><span class="header-section-number">0.2</span> 如何帮助完善本书<a href="index.html#如何帮助完善本书" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>可以参考<a href="https://neuropsychology.github.io/NeuroKit/resources/contributing.html#how-to-use-github-to-contribute">这个英文的教程</a>我们暂时还没有进行中文翻译,您也可以将这部分补充,这也是极大的贡献</p>
<p>可以参考<a href="https://neuropsychology.github.io/NeuroKit/resources/contributing.html#how-to-use-github-to-contribute">这个英文的教程</a>我们进行了大致的翻译</p>
<p>可能需要的前期知识:(1) 如何使用github;(2) 如何使用<a href="https://bookdown.org/">bookdown</a></p>
<p>大致可以分成如下几步:</p>
<p>第一,创建github账号,然后fork这个项目。<br />
Expand Down
4 changes: 2 additions & 2 deletions Book/_book/lesson-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,9 @@ <h3><span class="header-section-number">1.1.3</span> 为什么要学习R语言
<p>从做研究的角度来说,R可以在这三个方面提供强大的支持。</p>
<p><strong>科学性</strong></p>
<p>使用R有助于增强计算的可重复性。如果我们能够精确地重复我们的分析,并且得到相同的结果,那么我们的研究就更加可信。在讨论心理学研究的可重复性时,我们发现即使是有了公开的数据和代码,也很难保证研究的精确重复。最近的<a href="https://doi.org/10.1177/09567976221140828">一个研究</a>发现,在14篇文章中,只有一篇能够完全精确地重复出来。这表明我们在数据分析的过程中,很多微小的步骤如果没有被完整记录下来,就很难保证研究的可重复性。为了解决这个问题,现在越来越多的人鼓励使用编程语言,如R语言,来记录数据分析的每一步。这样,我们可以从原始数据开始,记录下所有的数据处理步骤,从而确保研究的可重复性。例如,我与合作者2020年发表的<a href="https://doi.org/10.1525/collabra.301">一篇文章</a>中,我们公开了所有的数据和代码,并且有小组检查了这些数据和代码,发现能够得到与我们报告中大致相同的结果。</p>
<p>R会提供新的统计方法。IJzerman 2018年的Collabra: Psychology这篇文章(<a href="https://doi.org/10.1525/collabra.165" class="uri">https://doi.org/10.1525/collabra.165</a>),我是合作者之一.当时也通过互联网来合作收集的数据。在这个文章当中,他就使用了机器学习的方法,叫做(条件)随机森林(conditional random forest)。它实际上是在机器学习里面常见的一个方法。它的特点就是说即便只有比较少的数据,也能够得到比较稳健的结果。当然这个<strong></strong>数据是相对于机器学习里面的小的数据,因为机器学习里面可能动则就是上十万百万的数据。相比而言,我们的数据是很小的,就几百人上千人。所以当拿到这1,000多人的数据之后,他想去探索这么多变量之间到底哪些变量之间有一个比较稳定的关系,他就采用了随机森林的方法,最后也发现他感兴趣的那个变量,就是身体的温度和这个社交网络的复杂程度是有关系的</p>
<p>R生态中有大量的统计方法。<a href="https://doi.org/10.1525/collabra.165">IJzerman等(2018, Collabra: Psychology)</a>这篇论文(我是合作者之一)就是一个例子.当时我们通过互联网合作收集数据。Hans IJzerman使用了机器学习的方法——(条件)随机森林(conditional random forest)。这个方法是在机器学习中常见的一个方法,它的特点是在数据较少时也能够得到比较稳健的结果。当然这里<strong>小数据</strong>是相对于计算机领域的数据来说是<em>小的</em>,因为他们可能动则就是十万百万的数据。当时拿到这1,000多人的数据后,Hans想去探索在我们测量的这么多变量中,到底有哪些变量能够稳定地预测核心体温,所以采用了随机森林的方法,最后我们发现最关心的那个变量——社交网络的复杂程度——确实能够预测体温</p>
<p><img src="pic/chp1/image-20230302201218927.png" style="zoom:67%;"/></p>
<p>R会提供更合适的方法。比方说我们实验室实验当中非常常用的反应时间,它基本上都是偏态的分布,对于这种偏态分布的数据到底应该采用什么样的一个模型,到底是用传统的线性模型还是应该用广义的线性模型。如果使用r,那我们可以很灵活的使用r里面比较新的一些回归模型的包。在这包里面我们可以使用最适合这个模型的,比方说GLM。我们甚至可以通过模型比较的方式找到哪一个模型是最适合的。也就是说正是因为在R有一个很强大的community,然后这里面有众多可以选择的r的工具包。这样我们就能够不仅仅是使用新的方法,它也可以帮助我们不断的去选出更加适合的方法</p>
<p>R生态中有比传统方法更合适的方法。比方说我们认知实验当中常需要分析反应时间(reaction times, RT)。RT数据基本上都是偏态的分布,对于这种偏态分布的数据应该采用什么统计模型?传统的线性模型还是广义的线性模型。在R语言中,我们可以很灵活的使用一些更灵活的回归模型的工具包。在这些包里面,可以在广义线性模型(generalized linear model, GLM)的框架下选择更适合RT分布的模型。我们甚至可以通过模型比较的方法找到哪一个模型是最适合的。正是因为R语言有强大的community和更多可能的工具包,为我们提供了多种选项。这样我们就能够不仅仅是使用新的方法,它也可以帮助不断选出更加适合的方法</p>
<p><img src="pic/chp1/image-20230302201236318.png" /></p>
<p><strong>美观</strong></p>
<p>R语言提供了强大的绘图功能,便于调整细节,可以帮助我们在数据分析的每个阶段进行可视化。如ggplot2,它允许用户调整图表的每一个细节,以更直观、美观的方式展示数据。 我们后面会讲可视化的进阶,那一章的时候我们会把ggplot这个最常见的画图软件里面的每一个细节都掰开讲,这里我们只是稍微展示一下。我们可以把原始数据和group level数据结合到一起,然后再把每个被试的数据,把它的分布画出来。</p>
Expand Down
2 changes: 1 addition & 1 deletion Book/_book/lesson-5.html
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ <h3><span class="header-section-number">5.4.2</span> 数值型(numeric)<a href="
<pre><code>## [1] 2</code></pre>
<div class="sourceCode" id="cb73"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb73-1"><a href="lesson-5.html#cb73-1" tabindex="-1"></a><span class="do">## 直接输入pi会返回圆周率</span></span>
<span id="cb73-2"><a href="lesson-5.html#cb73-2" tabindex="-1"></a>pi</span></code></pre></div>
<pre><code>## [1] 3.141593</code></pre>
<pre><code>## [1] 3.1416</code></pre>
<div class="sourceCode" id="cb75"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb75-1"><a href="lesson-5.html#cb75-1" tabindex="-1"></a><span class="do">## 幂运算</span></span>
<span id="cb75-2"><a href="lesson-5.html#cb75-2" tabindex="-1"></a><span class="dv">10</span><span class="sc">^</span><span class="dv">3</span></span></code></pre></div>
<pre><code>## [1] 1000</code></pre>
Expand Down
2 changes: 1 addition & 1 deletion Book/_book/search_index.json

Large diffs are not rendered by default.

Loading

0 comments on commit f27ea71

Please sign in to comment.