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
Returns
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
See Also
grouped_resample
Examples
## Load absolute temperature data set:data("AbsoluteTemperature")df=AbsoluteTemperature
## Find portions for climate zonespcs=table(df$z)/dim(df)[1]## Choose the approximate size of the new sample and compute resample sizesN=1000resamplesizes=as.integer(round(N*pcs))sum(resamplesizes)## Create the grouping matrixgroupmat=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")