-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.R
60 lines (38 loc) · 1.21 KB
/
main.R
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
library(broom)
set.seed(1459)
x <- 1L:10 + rnorm(10)
y <- 1L:10
# htest objects --------------------------
(cor_test <- cor.test(x = x, y = y))
str(cor_test)
# glance - a very brief summary
glance(cor_test)
wilcoxon_test <- wilcox.test(x = x, y = y)
glance(wilcoxon_test)
# lm objects ---------------------------------
(iris_model <- lm(Sepal.Length ~ Petal.Length + Species, data = iris))
str(iris_model) # no adjusted r^2
summary(iris_model)
str(summary(iris_model))
glance(iris_model)
# tidy - a model in a data.frame format (term-wise)
tidy(iris_model)
# augment - expand the input data using residuals and so on
augment(iris_model)
# aov objects ---------------------------------
(npk_model <- aov(yield ~ block + N * P + K, npk))
summary(npk_model)
tidy(npk_model)
augment(npk_model)
# Stan objects
library(rstan)
schools_dat <- list(J = 8,
y = c(28, 8, -3, 7, -1, 1, 18, 12),
sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
fit <- stan(file = "8schools.stan", data = schools_dat,
iter = 1000, chains = 4)
str(fit)
summary(fit)
dim(summary(fit)[[2]])
tidy(fit)
# other packages: sweep: tidy data for time series: https://github.com/business-science/sweep