The `pickMarble()`

function of the simpsons.marbles package is meant to
simulate easily the sampling (with replacement) of a marble from a collection
of marbles characterized by a tag indicating from which bag the marble
originates (one or two), its size (small or large) and color (blue or red).
The marbles are either poured together in a box or gathered by similar
features in pouches of different textures.

For instance, the marbles tagged one could be separated from the marbles tagged two; then, within each pouch, the large marbles could be separated from the small ones. In total, there are six ways to separate the marbles, one for each ordering of the marbles' features. In any case, the outer pouches contain marbles that share one of the three features, and the inner pouches contain marbles that share two of the three features.

Introduced by J. G. Bennett to discuss Simpson's paradox, the distribution of marbles is the following:

bag one bag two the box red blue red blue red blue large 12 18 8 2 20 20 small 3 7 21 9 24 16 The example qualifies as an instance of Simpson's reversal of associations becauseP(red|large, bag one) = 40% > P(red|small, bag one) = 30%,

P(red|large, bag two) = 80% > P(red|small, bag two) = 70%,

P(red|large) = 50% < P(red|small) = 60%.

In words, the proportion of large marbles that are red is bigger than the proportion of small marbles that are red in each original bag, and yet the proportion of large marbles that are red is not bigger than the proportion of small marbles that are red overall.

When the marbles are not poured together in the box, the probabilities to sample the outer pouches on the one hand and conditional probabilities to sample the inner pouches within an outer pouch on the other hand reflect the overall distribution of marbles and are thus possibly unequal. This may represent an unconscious ordering of textures by preference. For instance, in the above example, the probability to sample either of the outer pouch is 50%, and the conditional probability to sample the inner pouch of large marbles equals either 75% (if the marbles are tagged one) or 25% (otherwise).

```
> library("simpsons.marbles")
> example(pickMarble)
> source(system.file("testScripts/simulationStudy.R", package="simpsons.marbles"))
```

The first instruction loads the package. The second one runs the examples of
use of `pickMarble()`

that are included in its code. The third instruction
runs a simulation study.

Calling a "success" the drawing of a red marble, the simulation study focuses
on the four causal quantities defined as the probability of success under
interventions *do*(large) (imposing that the marble be large) or
*do*(bag one) (imposing that the marble be drawn from bag one) when the
approach to the gathering of the marbles by similar features decomposes either
as

- gather by size,
- gather by bag,

or as

- gather by bag,
- gather by size,

Note that it is easy to compute the true values, as opposed to estimators, of the four causal quantities. It appears that

P(red|*do*(large)) = 50% and P(red|*do*(bag one)) = 35%

when the approach to gathering is the first one above, and

P(red|*do*(large)) = 60% and P(red|*do*(bag one)) = 37.5%

otherwise.

The simulation study replicates one million independent draws of a marble from the box for each combination of intervention and approach to gathering. The estimators are merely the empirical proportions of marbles that are red in the simulated data sets. They are arguably fairly accurateâ€¦

This package was written by Antoine Chambaz, Isabelle Drouet and Sonia Memetea. To cite the package, see

```
> citation("simpsons.marbles")
> toBibtex(citation("simpsons.marbles"))
```

R package simpsons.marbles is only available via GitHub and can be installed in R as:

```
source("http://callr.org/install#achambaz/simpsons.marbles")
```

achambaz/simpsons.marbles documentation built on May 23, 2019, 9 p.m.

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.