Skip to content

Commit

Permalink
全书结构
Browse files Browse the repository at this point in the history
  • Loading branch information
XiangyunHuang committed Apr 27, 2024
1 parent 0f22517 commit 305baae
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ masr.tex
/.quarto/
.DS_Store
_book/
_book2/
old/
rsconnect/

*.log
*-tikzDictionary
*.aux
*_files/

code/poisson_log_glm
code/bernoulli_logit_glm_normal
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# 现代应用统计
# 现代应用统计与R语言

## Modern Applied Statistics with R

本书分三大部分,分别是机器学习、贝叶斯建模和空间分析。三个部分分别依据任务类型、模型种类和数据类型展开,不同的写作出发点将呈现不一样的写作风格。

- 机器学习

- 应用机器学习首先需要确定任务类型,根据不同的任务选用不同的算法。
- 机器学习根据任务类型分聚类、分类、回归和排序四个章节。

- 贝叶斯建模

- 贝叶斯建模从简单到复杂分频率和贝叶斯方法介绍主流的统计模型。
- 贝叶斯建模根据模型种类分概率推理框架、简单线性模型、广义线性模型、分层正态模型、混合效应模型、广义可加模型、高斯过程回归、时间序列回归等八个章节。

- 空间分析

- 应用空间分析方法需要根据空间数据类型(生成机理)而定,不同的生成机理将对应不同的建模和分析方法。
- 空间分析部分根据空间数据类型分点模式数据分析、点参考数据分析和区域数据分析三个章节。
2 changes: 1 addition & 1 deletion index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Book in early development. Planned release in 202X.
#| message: false
xfun::session_info(packages = c(
"mgcv", "glmnet", "lme4", "xgboost", "keras", "tensorflow",
"mgcv", "glmnet", "lme4", "xgboost", "keras3", "tensorflow",
"spaMM", "sf", "stars", "terra", "spdep", "igraph", "spatstat",
"INLA", "cmdstanr", "rstan", "brms", "ggplot2", "patchwork",
"knitr", "rmarkdown", "rsconnect", "magick", "pdftools"
Expand Down
2 changes: 1 addition & 1 deletion linear-models.qmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 线性模型 {#sec-linear-models}
# 简单线性模型 {#sec-linear-models}

```{r}
#| label: setup-cmdstan
Expand Down
26 changes: 25 additions & 1 deletion preamble.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
\usepackage[heading=true, UTF8]{ctex}
\PassOptionsToPackage{list=true}{subcaption}
\usepackage[heading=true,fontset=fandol,UTF8]{ctex}
\usepackage[nottoc]{tocbibind}
\usepackage[toc,lof,lot]{multitoc}

\usepackage[scale=0.85,semibold]{sourcecodepro}
\usepackage[angle=90,text=\textcopyright 黄湘云,color=gray,pos={0.5in,1.5in},scale=0.25]{draftwatermark}
% https://github.com/CTeX-org/ctex-kit/issues/331
\RecustomVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\},formatcom=\xeCJKVerbAddon}
\usepackage{bookmark}
\bookmarksetup{open,numbered,
depth=2, % 设置PDF的书签级别,2显示到subsection,3显示到subsubsection
addtohook={ %
\ifnum\bookmarkget{level}=0 % chapter
\bookmarksetup{bold} %
\fi
\ifnum\bookmarkget{level}=-1 % part
\bookmarksetup{color=orange,bold} %
\fi
}
}
\usepackage{animate}
\usepackage{bm} % \bm
\usepackage{mathrsfs}

\usepackage{makeidx}
\makeindex

Expand Down
10 changes: 8 additions & 2 deletions time-series-regression.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ plot(AirPassengers)
lines(air_passengers_ts, col = "red")
```

### tensorflow 框架 {#sec-google-tensorflow}


### nnet 包 {#sec-gnu-nnet}

前面介绍的模型都具有非常强的可解释性,比如各个参数对模型的作用。对于复杂的时间序列数据,比较适合用复杂的模型来拟合,看重模型的泛化能力,而不那么关注模型的机理。

Expand Down Expand Up @@ -530,7 +532,11 @@ lines(test_pred_ts, col = "green")

由图可知,在测试集上,随着时间拉长,预测越来越不准。

下面使用 tensorflow 包构造**多层**感知机训练数据和预测。
### keras3 包 {#sec-google-keras3}

[**keras3**](https://github.com/rstudio/keras) 包通过 **reticulate** 包引入 [Keras 3](https://github.com/keras-team/keras) 框架,这个框架支持 [TensorFlow](https://github.com/tensorflow/tensorflow)[PyTorch](https://github.com/pytorch/pytorch) 等多个后端,目前,keras3 包通过 [tensorflow 包](https://github.com/rstudio/tensorflow)仅支持 TensorFlow 后端。

下面使用 keras3 包构造多层感知机训练数据和预测。

```{r}
#| message: false
Expand Down

1 comment on commit 305baae

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Published on https://masr.netlify.app as production
🚀 Deployed on https://662cbd36606617aa11f85181--masr.netlify.app

Please sign in to comment.