1  Statistics

1.1 网络分析

1.1.1 问题引入与基本原理:

如何一步走完所有的桥?

欧拉在1736年发表的Solutio problematis ad geometriam situs pertinents中,首次用图论的方法解决了这个问题.

欧拉提出:

  • 每个陆地看作一个节点,每座桥看作一条边,这样就可简化图形

  • 若一个图中有两个或者两个以上的节点有奇数条边, 则不可能有一条路径只经过每条边一次而遍历所有边

This method created Graph Theory, which is the basics of the network analysis. The Graph Theory is studying the association between dots and edges.

The edges have directions(digraph) or none directions(undigraph) and weight representing the strength of relationship.

The main categories of network:

1.1.2 Code demo:

library(igraph)

Attaching package: 'igraph'
The following objects are masked from 'package:stats':

    decompose, spectrum
The following objects are masked from 'package:lubridate':

    %--%, union
The following objects are masked from 'package:dplyr':

    as_data_frame, groups, union
The following objects are masked from 'package:purrr':

    compose, simplify
The following object is masked from 'package:tidyr':

    crossing
The following object is masked from 'package:tibble':

    as_data_frame
The following object is masked from 'package:base':

    union
#无加权网络
graph(edges = c(1,2, 2,3, 3,4, 4,1),
          n = 4, 
          directed = F) -> g
plot(g)

#加权网络
graph(edges = c(1,2, 2,3, 3,4, 4,1),
          n = 4, 
          directed = F) -> g

E(g)$weight = c(5,3,8,2) # 赋予权重

plot(g,
     edge.width = E(g)$weight 
     )

#带方向的无加权网络
graph(edges = c(1,2, 2,3, 3,4, 4,1),
          n = 4, 
          directed = T) -> g


plot(g,
     edge.arrow.size = 0.5#箭头大小
     )

#带方向的无加权网络
graph(edges = c(1,2, 2,3, 3,4, 4,1),
          n = 4, 
          directed = T) -> g

E(g)$weight = c(5,3,8,2) # 赋予权重

plot(g,
     edge.arrow.size = 0.5,#箭头大小
     edge.width = E(g)$weight
     )

The history of network is short. Here is the figure of network history:

1.1.3 与相关分析的不同

线性相关分析在控制其他$X{i}, i $ 对 \(Y\)的影响的前提下, 估计\(X_{1}\)\(Y\)的影响

网络分析不特别区分自变量和因变量, 探索变量之间的相互关联.

1.2 网络的应用

网络分析常见的场景 - 社会网络分析, 节点是人 - 文献计量学中的网络分析 - 文本网络分析 - 症状网络分析

1.2.1 症状网络的作用

  • 症状网络特色和变化
  • 共病网络关键点识别
  • 因果关系探索
  • 探索干预对某种症状/整个症状网络的影响
  • 探索性图论进行群体识别

1.3 网络分析的研究设计

  • 选什么水平的数据, 维度还是条目(都可以)
  • 样本量多少?(至少300以上)

1.3.1 主要的统计步骤

  • 网络结构的设计与估计
  • 网络推断分析
  • 网络结构准确性分析
  1. 网络结构的估计 基本的网络结构类型
  • 相关矩阵网络

    • 加权网络;虚假关系多
  • 偏相关网络

    • 精简矩阵;只保留节点之间的直接连线 控制了网络中其他节点后两个节点之间仍然存在关系-直接联系 偏相关网络-加权相关网络, 考虑了两点间相关被其他节点影响的可能性(条件独立相关)
  • 自适应Lasso算法矩阵 专门用于估计偏相关网络的lasso变异, 把Lasso算法应用到偏相关网络结构(在偏相关网络基础上加入惩罚因子,减少关联相对较弱的连线)

    EBICglasso(拓展贝叶斯信息准则)

举例:

不同数据类型的匹配的方法: - 连续性数据 -> 基于偏相关分析的高斯图论 (qgraph package) - 分类数据 -> 伊辛模型(Ising model)(IsingFit package) 本质是多元回归, 边线代表某个节点能够预测其他节点的程度 - 连续型+分类数据 -> 混合网络模型(mgm package)

  1. 网络推断分析 全局推断:
  • 对整体进行分析

  • 对局部:比如小世界现象 和 密度.

    1. 创建小世界网络和随机网络

    2. 计算指标:平均路径长度, 聚集系数

    3. 比较指标:

      • 平均路径长度: 当前网络的平均路径长度应该小于或者接近随机网络的平均路径长度的1.5倍.

      • 聚集系数: 当前网络的聚集系数应该大于随机网络的聚集系数的2倍

      满足两个条件的是小世界网络

    局部推断:

    • 对网络中的节点和变现进行分析, 比如社区检测和节点的中心指标.

      1. 社区检测指将网络划分为若干个子集和社区,使得每个子集的内部节点连接紧密, 而不同子集之间的连接稀疏. 有助于识别网络的模块化结构, 揭示网络的功能区或群体, 如社交网络中的朋友圈, 生物网络中的功能模块.

      2. 节点的中心性指标: 衡量节点在网络中的重要性. 常见的指标包括: 度中心性, 接近中心性, 中介中心性.

  1. 网络准确性分析:

    用Bootstrapping多次重构网络来估计边线权重和中心指标的稳定性

    • 评估边权重的稳定性

    • 评估中心性指标的稳定性

    1.3.2 code demo:

2 LaTex数学公式速查表

2.1 LaTeX 数学公式速查表

2.1.1 1. 希腊字母

小写 代码 大写 代码
\(\alpha\) \alpha \(A\) A
\(\beta\) \beta \(B\) B
\(\gamma\) \gamma \(\Gamma\) \Gamma
\(\theta\) \theta \(\Theta\) \Theta
\(\pi\) \pi \(\Pi\) \Pi

2.1.2 2. 运算符

符号 代码 符号 代码
\(x \pm y\) x \pm y \(x \times y\) x \times y
\(x \div y\) x \div y \(x \cdot y\) x \cdot y
\(x \neq y\) x \neq y \(x \approx y\) x \approx y
\(x \geq y\) x \geq y \(x \leq y\) x \leq y

2.1.3 3. 上下标与分数

符号 代码
\(x^2\) x^2
\(x_1\) x_1
\(\frac{a}{b}\) \frac{a}{b}
\(\sqrt{x}\) \sqrt{x}
\(\sqrt[n]{x}\) \sqrt[n]{x}

2.1.4 4. 微积分

符号 代码
\(\frac{df}{dx}\) \frac{df}{dx}
\(\frac{\partial f}{\partial x}\) \frac{\partial f}{\partial x}
\(\int_a^b f(x)dx\) \int_a^b f(x)dx
\(\lim_{x \to 0} f(x)\) \lim_{x \to 0} f(x)
\(\sum_{i=1}^n x_i\) \sum_{i=1}^n x_i

2.1.5 5. 矩阵与向量

符号 代码
\(\begin{bmatrix} a & b \\ c & d \end{bmatrix}\) \begin{bmatrix} a & b \\ c & d \end{bmatrix}
\(\vec{v}\) \vec{v}
\(\mathbf{a} \cdot \mathbf{b}\) \mathbf{a} \cdot \mathbf{b}

2.1.6 6. 逻辑与集合

符号 代码 符号 代码
\(x \in A\) x \in A \(A \subset B\) A \subset B
\(A \cup B\) A \cup B \(A \cap B\) A \cap B
\(\forall x\) \forall x \(\exists x\) \exists x

2.1.7 7. 箭头与括号

符号 代码 符号 代码
\(x \to y\) x \to y \(f: X \to Y\) f: X \to Y
\(\left( \frac{a}{b} \right)\) \left( \frac{a}{b} \right) \(\|x\|\) \|x\|

2.1.8 8. 其他符号

符号 代码 符号 代码
\(\infty\) \infty \(\nabla\) \nabla
\(\partial\) \partial \(\dots\) \dots

3 发布到GitHub

3.0.1 Resubmit Content

resubmit content: step1: type git status in terminal next to console,

Step 1: Check Git Status​

  • Open the terminal and type:

    git status

    This will show the current state of your files.

​Step 2: Commit Changes​

  • If there are changes to submit, run:

    git commit -m "Initial commit"

​Step 3: Connect to GitHub​

  • To create a new GitHub repository, run in R (if using usethis):

    usethis::use_github()

    This will set up a new repository.

​Step 4: Push to GitHub (If Repository Exists)​

  • If you already have a GitHub repository, you can push your project directly:

    • ​Option 1:​​ Use the ​​“Push”​​ button in the top-right corner of RStudio.

    • ​Option 2:​​ Run in the terminal:

      git push origin main

​Step 5: Set Up GitHub Pages​

  • After pushing, go to your GitHub repository:

    • ​Settings​​ → ​​Pages​​ → Select the branch (e.g., main or gh-pages) and save.

4 报错总结

  1. 交叉引用没有对应的时候(在reference)里面对应就会报错,不能render book
  2. 连接不了github的token的原因是校园网,任何DNS的问题很可能就是校园网的问题.

5 Prompts :

Research writing: Please refine the translation of [text] from Chinese to English, ensuring that it is precise, scholarly, and aligns with the professional standards of psychology, psychiatry, or public health. The translation should remain faithful to the original meaning, avoiding unnecessary condensation, and the language should be fluent, stylistically appropriate, and meet the high standards of academic writing. Pay special attention to consistency in terminology, and, when necessary, consider the cultural context to ensure the translation is suitable for the target academic audience. 】