Following up on closure_generate(), you can call
closure_horns_analyze() to compute the horns index for each individual
sample and compute summary statistics on the distribution of these indices.
See horns() for the metric itself.
This adds more detail to the "horns" and "horns_uniform" columns in the
output of closure_generate(), where "horns" is the overall mean of the
per-sample indices found here.
closure_horns_histogram() draws a quick barplot to reveal the
distribution of horns values. The scale is fixed between 0 and 1.
closure_horns_analyze(data)closure_horns_histogram(
data,
bar_alpha = 0.8,
bar_color = "#5D3FD3",
bar_binwidth = 0.0025,
text_size = 12
)
closure_horns_analyze() returns a named list of two tibbles (data
frames):
horns_metrics: Summary statistics of the distribution of horns index values:
mean, uniform: same as horns and horns_uniform from
closure_generate()'s output.
sd: double. Standard deviation.
cv: double. Coefficient of variation, i.e., sd / mean.
mad: double. Median absolute deviation; see stats::mad().
min, median, max: double. Minimum, median, and maximum horns
index.
range: double. Equal to max - min.
horns_results:
id: integer. Uniquely identifies each horns index, just like their
corresponding samples in closure_generate().
horns: double. Horns index for each individual sample.
closure_horns_histogram() returns a ggplot object.
For closure_horns_analyze(), a list returned by
closure_generate(). For closure_horns_histogram(), a list returned by
closure_horns_analyze().
Numeric (length 1). Opacity of the bars. Default is 0.8.
String (length 1). Color of the bars. Default is
"#5D3FD3", a purple color.
Width of the bins that divide up the x-axis, passed on to
ggplot2::geom_histogram(). Default is 0.0025.
Numeric. Base font size in pt. Default is 12.
The "mad" column overrides a default of stats::mad(): adjusting
the result via multiplication by a constant (about 1.48). This assumes a
normal distribution, which generally does not seem to be the case with
horns index values. Here, the constant is set to 1.
data <- closure_generate(
mean = "2.9",
sd = "0.5",
n = 70,
scale_min = 1,
scale_max = 5
)
data_horns <- closure_horns_analyze(data)
data_horns
closure_horns_histogram(data_horns)
Run the code above in your browser using DataLab