Sampling_via_cluster: Stratified sampling by clusters or types

Description Usage Arguments Value See Also Examples

View source: R/Sampling.R

Description

Stratified sampling by clusters or types

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Sampling_via_cluster(
  x,
  num = length(x),
  replace = FALSE,
  order.value = NULL,
  ...
)

Sampling_by_sort(
  x,
  num = length(x),
  log10 = FALSE,
  n_group = 3,
  replace = TRUE
)

Arguments

x

A vector represents the cluster or type, only support numeric value now.

num

The number of sampling. Default as length(x)

replace

The way of sampling. See help(sample) for more details.

order.value

The vector used for ordering. Default is NULL.

...

Parameters of function Sampling_by_sort.

log10

Whether to log10-trans the order.value. Default is FALSE.

n_group

Number of group to be devided. Default is 3.

Value

Result of Sampling_via_cluster is the index of sampled items from the input x.

See Also

Other Algorithm assessment: Assessment_via_cluster(), Getting_Asses_results(), Score_algorithms_interval(), Score_algorithms_sort(), Scoring_system()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(FCMm)
x = round(runif(100, 1, 10))
table(x)
w_sampled = Sampling_via_cluster(x, 20)
table(x[w_sampled])


set.seed(1)
N <- 100
x <- stats::rlnorm(N)
ind1 <- Sampling_by_sort(x, N/2)
ind2 <- sample.int(length(x), N/2)

library(ggplot2)
ggplot() + 
geom_density(aes(x = x, color = "Total")) + 
geom_density(aes(x = x[ind1], color = "ind1"), alpha = 0.8) + 
geom_density(aes(x = x[ind2], color = "ind2"), alpha = 0.6) +
scale_x_log10()

bishun945/FCMm documentation built on Oct. 15, 2021, 6:43 p.m.