-
Notifications
You must be signed in to change notification settings - Fork 260
/
charpter_9_supplymentary.Rmd
94 lines (78 loc) · 1.87 KB
/
charpter_9_supplymentary.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## install.packages
```{r cars}
install.packages("easystats")
#加载easystats运行会需要到的辅助文件,确保运行不会出问题
easystats::install_suggested()
library(easystats)
```
##datawizard
```{r}
###Data manipulation
##选择、过滤、筛选等操作
mtcars
data_match(mtcars, data.frame(vs = 0, am = 1))
data_filter(mtcars, vs == 0 & am == 1)
data_extract(mtcars, "gear")
###Statistical transformations数据转换
##标准化数据
summary(swiss)
summary(standardize(swiss))
##数据旋转或转置
data_rotate(swiss)
##各个值与均值的差,离均差
center(anscombe)
##描述性摘要
data(iris)
describe_distribution(iris)
```
##correlation
```{r pressure, echo=FALSE}
results <- correlation(iris)
results
summary(results)
#可通过see包来进行可视化
library(tidyverse)
results %>%
summary(redundant = TRUE) %>%
plot()
#计算其它的相关
iris %>%
correlation(partial = TRUE) %>%
summary()
```
##parameters
```{r}
#Classical Regression Models
model <- lm(Sepal.Width ~ Petal.Length * Species + Petal.Width, data = iris)
model_parameters(model)
```
##performance
```{r}
#Linear model
m1 <- lm(mpg ~ wt + cyl, data = mtcars)
model_performance(m1)
#Logistic regression
m2 <- glm(vs ~ wt + mpg, data = mtcars, family = "binomial")
model_performance(m2)
#Linear mixed model
library(lme4)
m3 <- lmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy)
model_performance(m3)
#Models comparison
compare_performance(m1, m2, m3, rank = TRUE, verbose = FALSE)
```
## report
```{r pressure, echo=FALSE}
model <- glm(vs ~ mpg * drat, data = mtcars, family = "binomial")
report(model)
```
##Citation
```{r}
citation("easystats")
citation("datawizard")
```
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.