Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Sep 16, 2023
1 parent 819cbb7 commit 6e0e29e
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 49 deletions.
16 changes: 8 additions & 8 deletions book/articles/reference/comparisons.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -770,19 +770,19 @@ posterior using the function supplied to the

## Equivalence, Inferiority, Superiority

<p><code class="reqn">\theta</code> is an estimate, <code class="reqn">\sigma_\theta</code> its estimated standard error, and <code class="reqn">[a, b]</code> are the bounds of the interval supplied to the <code>equivalence</code> argument.
<p>$\theta$ is an estimate, $\sigma_\theta$ its estimated standard error, and $[a, b]$ are the bounds of the interval supplied to the <code>equivalence</code> argument.
</p>
<p>Non-inferiority:
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \leq a</code>
<li> <p>$H_0$: $\theta \leq a$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &gt; a</code>
<li> <p>$H_1$: $\theta > a$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - a)/\sigma_\theta</code>
<li> <p>$t=(\theta - a)/\sigma_\theta$
</p>
</li>
<li><p> p: Upper-tail probability
Expand All @@ -793,13 +793,13 @@ posterior using the function supplied to the
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \geq b</code>
<li> <p>$H_0$: $\theta \geq b$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &lt; b</code>
<li> <p>$H_1$: $\theta < b$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - b)/\sigma_\theta</code>
<li> <p>$t=(\theta - b)/\sigma_\theta$
</p>
</li>
<li><p> p: Lower-tail probability
Expand Down Expand Up @@ -844,7 +844,7 @@ posterior using the function supplied to the


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
library(marginaleffects)
Expand Down
2 changes: 1 addition & 1 deletion book/articles/reference/datagrid.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ explicitly defined are held at their mean or mode.


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
# The output only has 2 rows, and all the variables except `hp` are at their
Expand Down
16 changes: 8 additions & 8 deletions book/articles/reference/hypotheses.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,19 @@ For the Chi-squared test, the degrees of freedom are Q.

## Equivalence, Inferiority, Superiority

<p><code class="reqn">\theta</code> is an estimate, <code class="reqn">\sigma_\theta</code> its estimated standard error, and <code class="reqn">[a, b]</code> are the bounds of the interval supplied to the <code>equivalence</code> argument.
<p>$\theta$ is an estimate, $\sigma_\theta$ its estimated standard error, and $[a, b]$ are the bounds of the interval supplied to the <code>equivalence</code> argument.
</p>
<p>Non-inferiority:
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \leq a</code>
<li> <p>$H_0$: $\theta \leq a$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &gt; a</code>
<li> <p>$H_1$: $\theta > a$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - a)/\sigma_\theta</code>
<li> <p>$t=(\theta - a)/\sigma_\theta$
</p>
</li>
<li><p> p: Upper-tail probability
Expand All @@ -273,13 +273,13 @@ For the Chi-squared test, the degrees of freedom are Q.
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \geq b</code>
<li> <p>$H_0$: $\theta \geq b$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &lt; b</code>
<li> <p>$H_1$: $\theta < b$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - b)/\sigma_\theta</code>
<li> <p>$t=(\theta - b)/\sigma_\theta$
</p>
</li>
<li><p> p: Lower-tail probability
Expand All @@ -299,7 +299,7 @@ For the Chi-squared test, the degrees of freedom are Q.


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
library(marginaleffects)
Expand Down
2 changes: 1 addition & 1 deletion book/articles/reference/inferences.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
library(marginaleffects)
Expand Down
16 changes: 8 additions & 8 deletions book/articles/reference/marginal_means.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -431,19 +431,19 @@ posterior using the function supplied to the

## Equivalence, Inferiority, Superiority

<p><code class="reqn">\theta</code> is an estimate, <code class="reqn">\sigma_\theta</code> its estimated standard error, and <code class="reqn">[a, b]</code> are the bounds of the interval supplied to the <code>equivalence</code> argument.
<p>$\theta$ is an estimate, $\sigma_\theta$ its estimated standard error, and $[a, b]$ are the bounds of the interval supplied to the <code>equivalence</code> argument.
</p>
<p>Non-inferiority:
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \leq a</code>
<li> <p>$H_0$: $\theta \leq a$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &gt; a</code>
<li> <p>$H_1$: $\theta > a$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - a)/\sigma_\theta</code>
<li> <p>$t=(\theta - a)/\sigma_\theta$
</p>
</li>
<li><p> p: Upper-tail probability
Expand All @@ -454,13 +454,13 @@ posterior using the function supplied to the
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \geq b</code>
<li> <p>$H_0$: $\theta \geq b$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &lt; b</code>
<li> <p>$H_1$: $\theta < b$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - b)/\sigma_\theta</code>
<li> <p>$t=(\theta - b)/\sigma_\theta$
</p>
</li>
<li><p> p: Lower-tail probability
Expand Down Expand Up @@ -505,7 +505,7 @@ posterior using the function supplied to the


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
library(marginaleffects)
Expand Down
2 changes: 1 addition & 1 deletion book/articles/reference/plot_comparisons.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ the table below.


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
mod <- lm(mpg ~ hp * drat * factor(am), data = mtcars)
Expand Down
2 changes: 1 addition & 1 deletion book/articles/reference/plot_predictions.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ the table below.


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
mod <- lm(mpg ~ hp + wt, data = mtcars)
Expand Down
2 changes: 1 addition & 1 deletion book/articles/reference/plot_slopes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ the table below.


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
library(marginaleffects)
Expand Down
16 changes: 8 additions & 8 deletions book/articles/reference/predictions.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -574,19 +574,19 @@ posterior using the function supplied to the

## Equivalence, Inferiority, Superiority

<p><code class="reqn">\theta</code> is an estimate, <code class="reqn">\sigma_\theta</code> its estimated standard error, and <code class="reqn">[a, b]</code> are the bounds of the interval supplied to the <code>equivalence</code> argument.
<p>$\theta$ is an estimate, $\sigma_\theta$ its estimated standard error, and $[a, b]$ are the bounds of the interval supplied to the <code>equivalence</code> argument.
</p>
<p>Non-inferiority:
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \leq a</code>
<li> <p>$H_0$: $\theta \leq a$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &gt; a</code>
<li> <p>$H_1$: $\theta > a$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - a)/\sigma_\theta</code>
<li> <p>$t=(\theta - a)/\sigma_\theta$
</p>
</li>
<li><p> p: Upper-tail probability
Expand All @@ -597,13 +597,13 @@ posterior using the function supplied to the
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \geq b</code>
<li> <p>$H_0$: $\theta \geq b$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &lt; b</code>
<li> <p>$H_1$: $\theta < b$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - b)/\sigma_\theta</code>
<li> <p>$t=(\theta - b)/\sigma_\theta$
</p>
</li>
<li><p> p: Lower-tail probability
Expand Down Expand Up @@ -648,7 +648,7 @@ posterior using the function supplied to the


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
# Adjusted Prediction for every row of the original dataset
Expand Down
20 changes: 10 additions & 10 deletions book/articles/reference/slopes.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ including non-linear models with transformations (e.g., polynomials).
Uncertainty estimates are computed using the delta method.
</p>
<p>Numerical derivatives for the <code>slopes</code> function are calculated
using a simple epsilon difference approach: <code class="reqn">\partial Y / \partial X = (f(X + \varepsilon/2) - f(X-\varepsilon/2)) / \varepsilon</code>,
using a simple epsilon difference approach: $\partial Y / \partial X = (f(X + \varepsilon/2) - f(X-\varepsilon/2)) / \varepsilon$,
where f is the <code>predict()</code> method associated with the model class, and
<code class="reqn">\varepsilon</code> is determined by the <code>eps</code> argument.
$\varepsilon$ is determined by the <code>eps</code> argument.
</p>


Expand Down Expand Up @@ -556,19 +556,19 @@ posterior using the function supplied to the

## Equivalence, Inferiority, Superiority

<p><code class="reqn">\theta</code> is an estimate, <code class="reqn">\sigma_\theta</code> its estimated standard error, and <code class="reqn">[a, b]</code> are the bounds of the interval supplied to the <code>equivalence</code> argument.
<p>$\theta$ is an estimate, $\sigma_\theta$ its estimated standard error, and $[a, b]$ are the bounds of the interval supplied to the <code>equivalence</code> argument.
</p>
<p>Non-inferiority:
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \leq a</code>
<li> <p>$H_0$: $\theta \leq a$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &gt; a</code>
<li> <p>$H_1$: $\theta > a$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - a)/\sigma_\theta</code>
<li> <p>$t=(\theta - a)/\sigma_\theta$
</p>
</li>
<li><p> p: Upper-tail probability
Expand All @@ -579,13 +579,13 @@ posterior using the function supplied to the
</p>

<ul>
<li> <p><code class="reqn">H_0</code>: <code class="reqn">\theta \geq b</code>
<li> <p>$H_0$: $\theta \geq b$
</p>
</li>
<li> <p><code class="reqn">H_1</code>: <code class="reqn">\theta &lt; b</code>
<li> <p>$H_1$: $\theta < b$
</p>
</li>
<li> <p><code class="reqn">t=(\theta - b)/\sigma_\theta</code>
<li> <p>$t=(\theta - b)/\sigma_\theta$
</p>
</li>
<li><p> p: Lower-tail probability
Expand Down Expand Up @@ -630,7 +630,7 @@ posterior using the function supplied to the


## Examples
```{r}
```{r, warning=FALSE, message=FALSE}
library(marginaleffects)
Expand Down
14 changes: 12 additions & 2 deletions book/utils/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ rd2qmd = function(src) {

# superfluous header and footer
tmp = readLines(tmp_html)
tmp = gsub("\\eqn\\{.*\\}\\{.*\\}", "\\$\\1\\$", tmp)
tmp = tmp[(grep("</table>$", tmp)[1] + 1):length(tmp)]
tmp = tmp[seq_len(which("</div>" == tmp) - 3)]

Expand All @@ -107,9 +106,20 @@ rd2qmd = function(src) {
ex = gsub("&gt;", ">", ex)
ex = ex[!grepl("## Not run:", ex)]
ex = ex[!grepl("## End", ex)]
tmp = c(tmp[2:idx], "```{r}", "library(marginaleffects)", ex, "```")
tmp = c(tmp[2:idx], "```{r, warning=FALSE, message=FALSE}", "library(marginaleffects)", ex, "```")
}

# cleanup equations
tmp <- gsub(
'<code class="reqn">(.*?)&gt;(.*?)</code>',
'<code class="reqn">\\1>\\2</code>',
tmp)
tmp <- gsub(
'<code class="reqn">(.*?)&lt;(.*?)</code>',
'<code class="reqn">\\1<\\2</code>',
tmp)
tmp <- gsub('<code class="reqn">(.*?)</code>', '\\$\\1\\$', tmp)

# title
funname = tools::file_path_sans_ext(basename(src))
if (!is.null(title)) {
Expand Down

0 comments on commit 6e0e29e

Please sign in to comment.