# dirichlet_sample: Function which performs Dirichlet sampling In archetypal: Finds the Archetypal Analysis of a Data Frame

 dirichlet_sample R Documentation

## Function which performs Dirichlet sampling

### Description

It uses Dirichlet weights for creating sub-samples of initial data set.

### Usage

``````dirichlet_sample(in_data = NULL, sample_size = NULL,
replacement = NULL, rseed = NULL)
``````

### Arguments

 `in_data` The initial data frame that must be re-sampled. It must contain: an ID variable the variables of interest a grouping variable `sample_size` An integer for the size of the new sample `replacement` A logical input: TRUE/FALSE if replacement should be used or not, respectively `rseed` The random seed that will be used for setting initial A matrix. Useful for reproducible results

### Value

It returns a data frame with exactly the same variables as the initial one, except that group variable has now only the given value from input data frame.

### Author(s)

David Midgley

`grouped_resample`

### Examples

``````## Load absolute temperature data set:
data("AbsoluteTemperature")
df=AbsoluteTemperature
## Find portions for climate zones
pcs=table(df\$z)/dim(df)[1]
## Choose the approximate size of the new sample and compute resample sizes
N=1000
resamplesizes=as.integer(round(N*pcs))
sum(resamplesizes)
## Create the grouping matrix
groupmat=data.frame("Group_ID"=1:4,"Resample_Size"=resamplesizes)
groupmat
## Dirichlet resampling:
resample_dirichlet <- grouped_resample(in_data = df,grp_vector = "z",
grp_matrix = groupmat,replace = FALSE,
option = "Dirichlet", rseed = 20191220)
cat(dim(resample_dirichlet),"\n")
``````

archetypal documentation built on May 29, 2024, 8:46 a.m.