Skip to content

Commit 5a595b9

Browse files
committed
refactor
1 parent a5dc8ea commit 5a595b9

20 files changed

+59
-41
lines changed

data/scents.sav

1.25 KB
Binary file not shown.

notebooks/Correlation Analysis.Rmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ date: "`r format(Sys.time(), '%d %B %Y')`"
55
output: rmarkdown::github_document
66
---
77

8+
```{r echo=FALSE}
9+
knitr::opts_chunk$set(fig.path='figures/corr-')
10+
```
11+
812
```{r}
913
library(ggpubr)
1014
library(haven)

notebooks/Correlation_Analysis.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Correlation Analysis
22
================
33
Murat Koptur
4-
23 Ağustos 2018
4+
24 Ağustos 2018
55

66
``` r
77
library(ggpubr)
@@ -60,4 +60,4 @@ ggscatter(
6060
)
6161
```
6262

63-
![](Correlation_Analysis_files/figure-markdown_github/unnamed-chunk-4-1.png)
63+
![](figures/corr-unnamed-chunk-5-1.png)

notebooks/Factor Analysis.Rmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ author: "Murat Koptur"
44
date: "`r format(Sys.time(), '%d %B %Y')`"
55
output: rmarkdown::github_document
66
---
7+
8+
```{r echo=FALSE}
9+
knitr::opts_chunk$set(fig.path='figures/factor-')
10+
```
11+
712
```{r}
813
library(readr)
914
library(knitr)

notebooks/Factor_Analysis.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Factor Analysis
22
================
33
Murat Koptur
4-
23 Ağustos 2018
4+
24 Ağustos 2018
55

66
``` r
77
library(readr)
@@ -83,7 +83,7 @@ KMO(bfi)
8383
fa.parallel(bfi)
8484
```
8585

86-
![](Factor_Analysis_files/figure-markdown_github/unnamed-chunk-4-1.png)
86+
![](figures/factor-unnamed-chunk-5-1.png)
8787

8888
## Parallel analysis suggests that the number of factors = 6 and the number of components = 6
8989

@@ -97,4 +97,4 @@ bfi.fa <- fa(bfi, nfactors = 6, fm="pa", max.iter = 100)
9797
fa.diagram(bfi.fa)
9898
```
9999

100-
![](Factor_Analysis_files/figure-markdown_github/unnamed-chunk-5-1.png)
100+
![](figures/factor-unnamed-chunk-6-1.png)
Binary file not shown.

notebooks/Multiple Linear Regression with interaction terms.Rmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ date: "`r format(Sys.time(), '%d %B %Y')`"
55
output: rmarkdown::github_document
66
---
77

8+
```{r echo=FALSE}
9+
knitr::opts_chunk$set(fig.path='figures/multipleLin-')
10+
```
11+
812
```{r}
913
library(GGally)
1014
library(ggplot2)

notebooks/Multiple_Linear_Regression_with_interaction_terms.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Multiple Linear Regression with interaction terms
22
================
33
Murat Koptur
4-
23 Ağustos 2018
4+
24 Ağustos 2018
55

66
``` r
77
library(GGally)
@@ -69,13 +69,13 @@ ggplot(data = child_data_melted, aes(x = value)) +
6969

7070
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
7171

72-
![](Multiple_Linear_Regression_with_interaction_terms_files/figure-markdown_github/unnamed-chunk-3-1.png)
72+
![](figures/multipleLin-unnamed-chunk-4-1.png)
7373

7474
``` r
7575
ggpairs(child_data)
7676
```
7777

78-
![](Multiple_Linear_Regression_with_interaction_terms_files/figure-markdown_github/unnamed-chunk-4-1.png)
78+
![](figures/multipleLin-unnamed-chunk-5-1.png)
7979

8080
``` r
8181
child_data_scaled <- scale(child_data)

notebooks/Poisson Regression.Rmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ date: "`r format(Sys.time(), '%d %B %Y')`"
55
output: rmarkdown::github_document
66
---
77

8+
```{r echo=FALSE}
9+
knitr::opts_chunk$set(fig.path='figures/poisson-')
10+
```
11+
12+
813
```{r}
914
library(bayesplot)
1015
library(ggplot2)

notebooks/Poisson_Regression.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ ggplot(data = awards_melted, aes(x = value)) +
9191

9292
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
9393

94-
![](Poisson_Regression_files/figure-markdown_github/unnamed-chunk-4-1.png)
94+
![](figures/poisson-unnamed-chunk-5-1.png)
9595

9696
``` r
9797
awards$math <- scale(awards$math)
@@ -135,8 +135,8 @@ model2 <- stan_glm(num_awards ~ math + prog, data = awards, family = poisson,
135135
##
136136
## SAMPLING FOR MODEL 'count' NOW (CHAIN 1).
137137
##
138-
## Gradient evaluation took 0.00012 seconds
139-
## 1000 transitions using 10 leapfrog steps per transition would take 1.2 seconds.
138+
## Gradient evaluation took 0.000117 seconds
139+
## 1000 transitions using 10 leapfrog steps per transition would take 1.17 seconds.
140140
## Adjust your expectations accordingly!
141141
##
142142
##
@@ -153,9 +153,9 @@ model2 <- stan_glm(num_awards ~ math + prog, data = awards, family = poisson,
153153
## Iteration: 1800 / 2000 [ 90%] (Sampling)
154154
## Iteration: 2000 / 2000 [100%] (Sampling)
155155
##
156-
## Elapsed Time: 0.236298 seconds (Warm-up)
157-
## 0.256971 seconds (Sampling)
158-
## 0.493269 seconds (Total)
156+
## Elapsed Time: 0.289811 seconds (Warm-up)
157+
## 0.270276 seconds (Sampling)
158+
## 0.560087 seconds (Total)
159159
##
160160
##
161161
## SAMPLING FOR MODEL 'count' NOW (CHAIN 2).
@@ -178,15 +178,15 @@ model2 <- stan_glm(num_awards ~ math + prog, data = awards, family = poisson,
178178
## Iteration: 1800 / 2000 [ 90%] (Sampling)
179179
## Iteration: 2000 / 2000 [100%] (Sampling)
180180
##
181-
## Elapsed Time: 0.272622 seconds (Warm-up)
182-
## 0.282284 seconds (Sampling)
183-
## 0.554906 seconds (Total)
181+
## Elapsed Time: 0.281356 seconds (Warm-up)
182+
## 0.258399 seconds (Sampling)
183+
## 0.539755 seconds (Total)
184184
##
185185
##
186186
## SAMPLING FOR MODEL 'count' NOW (CHAIN 3).
187187
##
188-
## Gradient evaluation took 3.1e-05 seconds
189-
## 1000 transitions using 10 leapfrog steps per transition would take 0.31 seconds.
188+
## Gradient evaluation took 3e-05 seconds
189+
## 1000 transitions using 10 leapfrog steps per transition would take 0.3 seconds.
190190
## Adjust your expectations accordingly!
191191
##
192192
##
@@ -203,15 +203,15 @@ model2 <- stan_glm(num_awards ~ math + prog, data = awards, family = poisson,
203203
## Iteration: 1800 / 2000 [ 90%] (Sampling)
204204
## Iteration: 2000 / 2000 [100%] (Sampling)
205205
##
206-
## Elapsed Time: 0.280228 seconds (Warm-up)
207-
## 0.257846 seconds (Sampling)
208-
## 0.538074 seconds (Total)
206+
## Elapsed Time: 0.273531 seconds (Warm-up)
207+
## 0.267135 seconds (Sampling)
208+
## 0.540666 seconds (Total)
209209
##
210210
##
211211
## SAMPLING FOR MODEL 'count' NOW (CHAIN 4).
212212
##
213-
## Gradient evaluation took 3e-05 seconds
214-
## 1000 transitions using 10 leapfrog steps per transition would take 0.3 seconds.
213+
## Gradient evaluation took 3.1e-05 seconds
214+
## 1000 transitions using 10 leapfrog steps per transition would take 0.31 seconds.
215215
## Adjust your expectations accordingly!
216216
##
217217
##
@@ -228,9 +228,9 @@ model2 <- stan_glm(num_awards ~ math + prog, data = awards, family = poisson,
228228
## Iteration: 1800 / 2000 [ 90%] (Sampling)
229229
## Iteration: 2000 / 2000 [100%] (Sampling)
230230
##
231-
## Elapsed Time: 0.256981 seconds (Warm-up)
232-
## 0.29209 seconds (Sampling)
233-
## 0.549071 seconds (Total)
231+
## Elapsed Time: 0.248926 seconds (Warm-up)
232+
## 0.250404 seconds (Sampling)
233+
## 0.49933 seconds (Total)
234234

235235
``` r
236236
summary(model2)
@@ -253,18 +253,18 @@ summary(model2)
253253
## (Intercept) -0.5 0.2 -0.9 -0.6 -0.5 -0.4 -0.1
254254
## math 0.3 0.1 0.2 0.3 0.3 0.4 0.5
255255
## prog2 0.5 0.2 0.0 0.3 0.5 0.6 0.9
256-
## prog3 0.6 0.3 0.1 0.4 0.6 0.7 1.1
256+
## prog3 0.6 0.3 0.1 0.4 0.6 0.7 1.0
257257
## mean_PPD 1.0 0.1 0.8 0.9 1.0 1.0 1.2
258-
## log-posterior -252.2 1.4 -255.9 -252.8 -251.8 -251.1 -250.4
258+
## log-posterior -252.2 1.4 -255.8 -252.9 -251.9 -251.1 -250.4
259259
##
260260
## Diagnostics:
261261
## mcse Rhat n_eff
262-
## (Intercept) 0.0 1.0 1650
263-
## math 0.0 1.0 2690
264-
## prog2 0.0 1.0 1911
265-
## prog3 0.0 1.0 1820
266-
## mean_PPD 0.0 1.0 3438
267-
## log-posterior 0.0 1.0 1664
262+
## (Intercept) 0.0 1.0 1997
263+
## math 0.0 1.0 2485
264+
## prog2 0.0 1.0 2291
265+
## prog3 0.0 1.0 2054
266+
## mean_PPD 0.0 1.0 3751
267+
## log-posterior 0.0 1.0 1624
268268
##
269269
## For each parameter, mcse is Monte Carlo standard error, n_eff is a crude measure of effective sample size, and Rhat is the potential scale reduction factor on split chains (at convergence Rhat=1).
270270

@@ -273,19 +273,19 @@ posterior_interval(model2, prob = 0.95)
273273
```
274274

275275
## 2.5% 97.5%
276-
## (Intercept) -0.92868856 -0.1355184
277-
## math 0.18303731 0.4864172
278-
## prog2 0.02950207 0.9384001
279-
## prog3 0.08602003 1.0644818
276+
## (Intercept) -0.89457959 -0.1447066
277+
## math 0.18111692 0.4915252
278+
## prog2 0.03168288 0.9214785
279+
## prog3 0.07135645 1.0449510
280280

281281
``` r
282282
plot(model2, plotfun = "areas", prob = 0.95)
283283
```
284284

285-
![](Poisson_Regression_files/figure-markdown_github/unnamed-chunk-8-1.png)
285+
![](figures/poisson-unnamed-chunk-9-1.png)
286286

287287
``` r
288288
pp_check(model2)
289289
```
290290

291-
![](Poisson_Regression_files/figure-markdown_github/unnamed-chunk-9-1.png)
291+
![](figures/poisson-unnamed-chunk-10-1.png)

0 commit comments

Comments
 (0)