subsample | R Documentation |

A function to sample from a SITAR dataset for experimental design purposes.
Two different sampling schemes are offered, based on the values of `id`

and `x`

.

```
subsample(x, id, data, prob = 1, xlim = NULL)
```

`x` |
vector of age. |

`id` |
factor of subject identifiers. |

`data` |
dataframe containing |

`prob` |
scalar defining sampling probability. See Details. |

`xlim` |
length 2 vector defining range of |

With the first sampling scheme `xlim`

is set to `NULL`

(default),
and rows of `data`

are sampled with probability `prob`

without
replacement. With the second sampling scheme `xlim`

is set to a range
within `range(x)`

. Subjects `id`

are then sampled with
probability `prob`

without replacement, and all their rows where
`x`

is within `xlim`

are selected. The second scheme is useful
for testing the power of the model to predict later growth when data only up
to a certain age are available. Setting `xlim`

to `range(x)`

allows data to be sampled by subject. The returned value can be used as the
`subset`

argument in `sitar`

or `update.sitar`

.

Returns a logical the length of `x`

where `TRUE`

indicates
a sampled value.

Tim Cole tim.cole@ucl.ac.uk

`sitar`

```
## draw 50% random sample
s50 <- subsample(age, id, heights, prob=0.5)
## truncate age range to 7-12 for 50% of subjects
t50 <- subsample(age, id, heights, prob=0.5, xlim=c(7, 12))
```

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.