draw_sample: Draw Samples with the Desired Properties from a Data Set

View source: R/draw_sample.R

draw_sampleR Documentation

Draw Samples with the Desired Properties from a Data Set

Description

A function to sample data with desired properties.

Usage

draw_sample(
  dist,
  n,
  skew,
  kurts,
  replacement = FALSE,
  save.output = FALSE,
  output_name = c("sample", "default")
)

Arguments

dist

data frame:consists of id and scores with no missing

n

numeric: desired sample size

skew

numeric: the skewness value

kurts

numeric: the kurtosis value

replacement

logical:Sample with or without replacement? (default is FALSE).

save.output

logical: should the output be saved into a text file? (default is FALSE).

output_name

character: a vector of two components. The first component is the name of the output file, user can change the second component.

Details

The execution of the function may take some time since it tries to obtain the specified value for skewness and kurtosis.

Value

This function returns a list including following:

  • a matrix: Descriptive statistics of the given data, the reference vector and the sample.

  • a data frame: The id's and scores of the sample

  • graph: Histograms for the “data” and the “sample”

References

Fleishman AI (1978). A Method for Simulating Non-normal Distributions. Psychometrika, 43, 521-532. doi: 10.1007/BF02293811.

Fialkowski, A. C. (2018). SimMultiCorrData: Simulation of Correlated Data with Multiple #' Variable Types. R package version 0.2.2. Retrieved from https://cran.r-project.org/web/packages/SimMultiCorrData/index.html

Atalay Kabasakal, K. & Gunduz, T. (2020). Drawing a Sample with Desired Properties from Population in R Package “drawsample”.Journal of Measurement and Evaluation in Education and Psychology,11(4),405-429. doi: 10.21031/epod.790449

Examples

# Example data provided with package
data(example_data)
# First 6 rows of the example_data
head(example_data)
# Draw a sample based on Score_1(from negatively skewed to normal)
output1 <- draw_sample(dist=example_data[,c(1,2)],n=200,skew = 0,kurts = 0,
save.output=FALSE) # Histogram of the reference data set
# descriptive statistics of the given data,reference data, and drawn sample
output1$desc
# First 6 rows of the drawn sample
head(output1$sample)
# Histogram of the given data set and drawn sample
output1$graph
## Not run: 
# Draw a sample based on Score_2 (from negatively skewed to positively skewed)
# draw_sample(dist=example_data[,c(1,3)],n=200,skew = 1,kurts = 1,
# output_name = c("sample", "1"))
# Draw a sample based on Score_2 (from negatively skewed to positively skewed
# with replacement)
# draw_sample(dist=example_data[,c(1,3)],n=200,skew = 0.5,kurts = 0.4,
# replacement=TRUE,output_name = c("sample", "2"))

## End(Not run)

drawsample documentation built on Sept. 6, 2022, 1:06 a.m.