Description Usage Arguments Details Value See Also Examples

A model for case-control studies with optional prior distributions for the coefficients, intercept, and auxiliary parameters.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |

`formula, data, subset, na.action` |
Same as for `data` is specified (and is a data frame) many post-estimation
functions (including `update` , `loo` , `kfold` ) are not
guaranteed to work properly. | |||||||||||

`...` |
Further arguments passed to the function in the rstan
package ( | |||||||||||

`strata` |
A factor indicating the groups in the data where the number of
successes (possibly one) is fixed by the research design. It may be useful
to use | |||||||||||

`prior` |
The prior distribution for the regression coefficients.
See the priors help page for details on the families and
how to specify the arguments for all of the functions in the table above.
To omit a prior —i.e., to use a flat (improper) uniform prior—
| |||||||||||

`prior_covariance` |
Cannot be | |||||||||||

`prior_PD` |
A logical scalar (defaulting to | |||||||||||

`algorithm` |
A string (possibly abbreviated) indicating the
estimation approach to use. Can be | |||||||||||

`adapt_delta` |
Only relevant if | |||||||||||

`QR` |
A logical scalar defaulting to | |||||||||||

`sparse` |
A logical scalar (defaulting to |

The `stan_clogit`

function is mostly similar in syntax to
`clogit`

but rather than performing maximum
likelihood estimation of generalized linear models, full Bayesian
estimation is performed (if `algorithm`

is `"sampling"`

) via
MCMC. The Bayesian model adds priors (independent by default) on the
coefficients of the GLM.

The `data.frame`

passed to the `data`

argument must be sorted by
the variable passed to the `strata`

argument.

The `formula`

may have group-specific terms like in
`stan_glmer`

but should not allow the intercept to vary by the
stratifying variable, since there is no information in the data with which
to estimate such deviations in the intercept.

A stanreg object is returned
for `stan_clogit`

.

`stanreg-methods`

and
`clogit`

.

The vignette for Bernoulli and binomial models, which has more
details on using `stan_clogit`

.
http://mc-stan.org/rstanarm/articles/

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
dat <- infert[order(infert$stratum), ] # order by strata
post <- stan_clogit(case ~ spontaneous + induced + (1 | education),
strata = stratum,
data = dat,
subset = parity <= 2,
QR = TRUE,
chains = 2, iter = 500) # for speed only
nd <- dat[dat$parity > 2, c("case", "spontaneous", "induced", "education", "stratum")]
# next line would fail without case and stratum variables
pr <- posterior_linpred(post, newdata = nd, transform = TRUE) # transform=TRUE gives probabilities
# not a random variable b/c probabilities add to 1 within strata
all.equal(rep(sum(nd$case), nrow(pr)), rowSums(pr))
``` |

```
Loading required package: Rcpp
rstanarm (Version 2.17.4, packaged: 2018-04-13 01:51:52 UTC)
- Do not expect the default priors to remain the same in future rstanarm versions.
Thus, R scripts should specify priors explicitly, even if they are just the defaults.
- For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores())
- Plotting theme set to bayesplot::theme_default().
SAMPLING FOR MODEL 'bernoulli' NOW (CHAIN 1).
Gradient evaluation took 0.000102 seconds
1000 transitions using 10 leapfrog steps per transition would take 1.02 seconds.
Adjust your expectations accordingly!
Iteration: 1 / 500 [ 0%] (Warmup)
Iteration: 50 / 500 [ 10%] (Warmup)
Iteration: 100 / 500 [ 20%] (Warmup)
Iteration: 150 / 500 [ 30%] (Warmup)
Iteration: 200 / 500 [ 40%] (Warmup)
Iteration: 250 / 500 [ 50%] (Warmup)
Iteration: 251 / 500 [ 50%] (Sampling)
Iteration: 300 / 500 [ 60%] (Sampling)
Iteration: 350 / 500 [ 70%] (Sampling)
Iteration: 400 / 500 [ 80%] (Sampling)
Iteration: 450 / 500 [ 90%] (Sampling)
Iteration: 500 / 500 [100%] (Sampling)
Elapsed Time: 0.371801 seconds (Warm-up)
0.105303 seconds (Sampling)
0.477104 seconds (Total)
SAMPLING FOR MODEL 'bernoulli' NOW (CHAIN 2).
Gradient evaluation took 4e-05 seconds
1000 transitions using 10 leapfrog steps per transition would take 0.4 seconds.
Adjust your expectations accordingly!
Iteration: 1 / 500 [ 0%] (Warmup)
Iteration: 50 / 500 [ 10%] (Warmup)
Iteration: 100 / 500 [ 20%] (Warmup)
Iteration: 150 / 500 [ 30%] (Warmup)
Iteration: 200 / 500 [ 40%] (Warmup)
Iteration: 250 / 500 [ 50%] (Warmup)
Iteration: 251 / 500 [ 50%] (Sampling)
Iteration: 300 / 500 [ 60%] (Sampling)
Iteration: 350 / 500 [ 70%] (Sampling)
Iteration: 400 / 500 [ 80%] (Sampling)
Iteration: 450 / 500 [ 90%] (Sampling)
Iteration: 500 / 500 [100%] (Sampling)
Elapsed Time: 0.281446 seconds (Warm-up)
0.10516 seconds (Sampling)
0.386606 seconds (Total)
[1] TRUE
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.