cluster.resample {cfdecomp} | R Documentation |
Cluster Resampling: resampling long format longitudinal or otherwise clustered data
Description
Cluster Resampling: resampling long format longitudinal or otherwise clustered data
Usage
cluster.resample(data, cluster.name, size = NA, newID = FALSE)
Arguments
data |
a data frame containing the variables in the model. |
cluster.name |
the name (as a character) of the column containing the cluster identifiers. |
size |
a non-negative integer giving the number of items to choose, i.e. the number of clusters to resample. If not specified, takes the original data cluster size. |
newID |
if set to TRUE, gives each replicant a new ID, rather than having the old ID appear multiple times. This might be needed if you work with e.g. cluster fixed effects |
Value
returns a new dataframe with resampled clusters
Examples
table(cfd.example.data$id)
# every ID appears 5 times
cfd.example.sample <- cluster.resample(cfd.example.data, cluster.name='id')
table(cfd.example.sample$id)
# some ID's now don't appear, and some appear more times (multiples of 5)
# the important part is that if a person (id) is resampled, all their rows of data are taken
# i.e. the function resamples clusters, rather than rows.
# this has produced 1 resample, so generally this function would be used
# inside a loop where it is used multiple times
# we use this function inside our decomposition functions when cluster.sample is
# set to TRUE in those functions.
[Package cfdecomp version 0.4.0 Index]