Skip to content

Commit

Permalink
does pdf work with travis now?
Browse files Browse the repository at this point in the history
  • Loading branch information
benwhalley committed May 20, 2019
1 parent adb6421 commit cf12a97
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ r_github_packages:
script:
- |
Rscript -e 'bookdown::render_book("index.Rmd", "bookdown::gitbook")'
# Rscript -e 'bookdown::render_book("index.Rmd", "bookdown::pdf_book")'
Rscript -e 'bookdown::render_book("index.Rmd", "bookdown::pdf_book")'
deploy:
provider: pages
Expand Down
18 changes: 9 additions & 9 deletions linear-models.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ size) and `wt` (car weight):

```{r}
mtcars %>%
select(mpg, disp, wt) %>%
pairs
select(mpg, disp, wt) %>%
pairs
```

Before running any model, we should ask outselves: "what question we are trying
Expand Down Expand Up @@ -579,9 +579,9 @@ inputs.

However, be cautious when standardising. You will sometimes see people interpret
standardised coefficients in terms of 'relative importance' of the predictors.
For example, they might say that if $\beta^1 = .2$ and $\beta^2 = .4$ then
$\beta^2$ is twice as important as $\beta^$. Although this is appealing, it's
not always valid.
For example, they might say that if $\beta^{1}= .2$ and $\beta^{2} = .4$ then
$\beta^{2}$ is twice as important as $\beta^{1}$. Although this is appealing,
it's not always valid.

The main problem is that you don't always know whether you have a full range of
values of predictors in your sample. For example, imagine a case where the a
Expand All @@ -591,9 +591,9 @@ general population.
```{r, include=F}
set.seed(1234)
incomes <- data_frame(age = round(rnorm(1000, 40, 15)),
gender = sample(0:1, 1000, replace=T),
income = round(rnorm(1000, 30000, 1000) + 30*age + 1000 * gender)) %>%
mutate(gender=factor(gender, labels=c("F", "M")))
gender = sample(0:1, 1000, replace=T),
income = round(rnorm(1000, 30000, 1000) + 30*age + 1000 * gender)) %>%
mutate(gender=factor(gender, labels=c("F", "M")))
```

We can plot these data to show the effect of age, and gender:
Expand Down Expand Up @@ -627,7 +627,7 @@ constant across the range of ages:

```{r}
younger.incomes <- incomes %>%
filter(age<40)
filter(age<40)
m2 <- lm(income~age+gender, data=younger.incomes)
coef(m2)
Expand Down
6 changes: 3 additions & 3 deletions link-functions.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ You can think of the solution as coming in two steps:

#### Step 1 {-}

We can transform a probability on the 0---1 scale to a 0 \rightarrow ∞ scale by
converting it to _odds_, which are expressed as a ratio:
We can transform a probability on the 0---1 scale to a $0 \rightarrow ∞$ scale
by converting it to _odds_, which are expressed as a ratio:

$$\textrm{odds} = \dfrac{\textrm{probability}}{1-\textrm{probability}}$$
$$odds = \dfrac{p}{1-p}$$

Probabilities and odds ratios are two _equivalent_ ways of expressing the same
idea.
Expand Down
17 changes: 16 additions & 1 deletion power-analysis.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ We now use the `powerSim` function to use our tweaked model to:
- count how many times (i.e., for what proportion) we get a significant _p_
value

```{r}
```{r include=F, echo=T}
power.sim <- powerSim(model.of.interest, nsim=100)
```

```{r}
power.sim
```

Expand All @@ -82,7 +85,13 @@ to see what power we have to detect an effect of x = .8:

```{r}
fixef(model.of.interest)['x'] <- .8
```

```{r include=F, echo=T}
power.sim <- powerSim(model.of.interest, nsim=100)
```

```{r}
power.sim
```

Expand All @@ -98,7 +107,13 @@ And we could simulate increasing the variance parameter for `g` to 0.5:

```{r}
VarCorr(model.of.interest)['g'] <- .5
```

```{r include=F, echo=T}
power.sim <- powerSim(model.of.interest, nsim=100)
```

```{r}
power.sim
```

Expand Down

0 comments on commit cf12a97

Please sign in to comment.