Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{example} fails unless {theorem} exists in document #291

Closed
JeffreyRacine opened this issue Jan 7, 2017 · 9 comments
Closed

{example} fails unless {theorem} exists in document #291

JeffreyRacine opened this issue Jan 7, 2017 · 9 comments
Labels
bug an unexpected problem or unintended behavior
Milestone

Comments

@JeffreyRacine
Copy link

JeffreyRacine commented Jan 7, 2017

Greetings,

Using the minimal example (index.Rmd below), the following demonstrates the problem. If the environment e.g. ```{theorem} does not exist somewhere (it can precede or proceed ```{example}) in the document then the following error is thrown:

output file: bookdown-demo.knit.md

! LaTeX Error: Environment example undefined.

Error: Failed to compile bookdown-demo.tex. See bookdown-demo.log for more info.
Execution halted

Exited with status 1.

If you compile the code below all is well, remove ```{theorem} and it fails. Thanks!

--- 
title: "A Minimal Book Example"
author: "Yihui Xie"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
output: bookdown::gitbook
documentclass: book
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
github-repo: rstudio/bookdown-demo
description: "This is a minimal example of using the bookdown package to write a book. The output format for this example is bookdown::gitbook."
---

```{theorem}
Test
```

```{example}
Test
```
@yihui yihui added the bug an unexpected problem or unintended behavior label Jan 9, 2017
@yihui yihui added this to the v0.4 milestone Jan 9, 2017
@yihui yihui closed this as completed in 577a1b7 Jan 9, 2017
@yihui
Copy link
Member

yihui commented Jan 9, 2017

Should be fixed now. Thanks for the report!

@JeffreyRacine
Copy link
Author

JeffreyRacine commented Jan 9, 2017 via email

@JeffreyRacine
Copy link
Author

JeffreyRacine commented Jan 9, 2017 via email

@yihui
Copy link
Member

yihui commented Jan 9, 2017

Could you reply the issue on Github? The email attachment won't be sent here automatically.

@JeffreyRacine
Copy link
Author

Certainly...

screen shot 2017-01-09 at 17 50 34 jan 9 2017

@JeffreyRacine
Copy link
Author

JeffreyRacine commented Jan 9, 2017

Following up with code... there is a space in the code... note that html output is great, just not the PDF...

For example, to test the hypothesis that $\rho_1=0$ and $\rho_2=0$, we could use the $\mathcal{Q}_{lb}$ statistic given by $T(T+2)(\hat\rho_1^2/(T-1)+\hat\rho_2^2/(T-2))$ and test the hypothesis by comparing this statistic with a critical value taken from a $\chi^2_{(2)}$ distribution (i.e. a $\chi^2$ random variable having two degrees of freedom such as the 5% level critical value `r format(qchisq(0.95,df=2),digits=3)` obtained via `qchisq(0.95,df=2)`).

```{example}

Let's consider a simple example where you are given $\hat\rho_1$ and $\hat\rho_2$ and $T$ (the length of the series) and then manually conduct individual and joint tests for white noise and report the outcome of the test.

Supposed that we wished to test $H_0\colon\rho_1=0$ based on $T=100$ realizations of a time series, and we computed $\hat\rho_1=0.15121$, $Var[\hat\rho_1]=1/100=.01$, hence $Z=\hat\rho_1/\sqrt{Var[\hat\rho_1]}=0.15121/.1=1.5121$. We would fail to reject the null at all conventional levels. You might ask yourself exactly what this failure to reject the null means in the current context.

If we wished to test $H_0\colon\rho_2=0$ and we computed $\hat\rho_2=0.069739$, $Var[\hat\rho_2]=(1+2\times 0.15121^2)/100=  0.0104573$, hence $Z=\hat\rho_2/\sqrt{Var[\hat\rho_2]}=0.069739/ 0.102260=0.68197$. Again, we would fail to reject the null at all conventional levels.

If we wished to test $H_0\colon\rho_1=0\cap\rho_2=0$, then $\mathcal{Q}_{lb}=100(100+2)[0.15121^2/(100-1)+0.069739^2/(100-2)]$ which equals $10200[0.022865/99+ 0.0048635/98]$ which equals $2.86194$. For $\alpha=0.05$, $\chi^2_{2,1-\alpha}=5.99147$ so again we would fail to reject the null.

```

@yihui
Copy link
Member

yihui commented Jan 10, 2017

That is a separate issue. You can add these lines of LaTeX code to your preamble to increase the spacing: https://github.com/rstudio/bookdown/blob/4e94c8d499/inst/examples/latex/preamble.tex#L92-L98 If you don't know how, here is the documentation: https://bookdown.org/yihui/bookdown/yaml-options.html (use the in_header option).

Source of the solution: http://tex.stackexchange.com/q/85400/9128

@JeffreyRacine
Copy link
Author

JeffreyRacine commented Jan 10, 2017 via email

@github-actions
Copy link

github-actions bot commented Nov 6, 2020

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants