Title: | A Simulation Tool to Determine the Required Sample Size for Repertory Grid Studies |
---|---|
Description: | Simulation tool to facilitate determination of required sample size to achieve category saturation for studies using multiple repertory grids in conjunction with content analysis. |
Authors: | Mark Heckmann [aut, cre], Lukas Burk [aut] |
Maintainer: | Mark Heckmann <[email protected]> |
License: | GPL-3 |
Version: | 0.6 |
Built: | 2024-11-03 03:50:49 UTC |
Source: | https://github.com/markheckmann/gridsampler |
gridsampler - A sample size simulation software for repertory grid studies
Green, B. (2004). Personal construct psychology and content analysis. Personal Construct Theory & Practice, 1(3), 82-91.
Jankowicz, D. (2004). The easy guide to repertory grids. Chichester, England: John Wiley & Sons.
Calculate probability for getting certain proportion of categories with at least m constructs
calc_probabilities(r, n, ms, min.props = c(0.9, 0.95, 0.99))
calc_probabilities(r, n, ms, min.props = c(0.9, 0.95, 0.99))
r |
A dataframe. The result returned from |
n |
Vector of n for which to calculate probabilities. |
ms |
minimal number of constructs in each category |
min.props |
Proportion of categores to contain at least m constructs. |
Other Utilities: expected_frequencies
,
prob_categories
prob <- dexp(1:30, .05) n <- seq(10, 80, by = 20) r <- sim_n_persons_x_times_many_n(prob, n, a = 7, times = 100) dd <- calc_probabilities(r, n, ms=1:5, min.props = c(0.9, .95, 1)) head(dd)
prob <- dexp(1:30, .05) n <- seq(10, 80, by = 20) r <- sim_n_persons_x_times_many_n(prob, n, a = 7, times = 100) dd <- calc_probabilities(r, n, ms=1:5, min.props = c(0.9, .95, 1)) head(dd)
Draw and redraw results of simulation
draw_multiple_n_persons_x_times(d)
draw_multiple_n_persons_x_times(d)
d |
A dataframe as returned by |
Other Plotting: draw_n_person_sample
## simulate prob <- dexp(1:30, .05) # probabilities for categories N <- seq(10, 80, by = 10) # smaple sizes to simulate r <- sim_n_persons_x_times_many_n(prob, n = N, a = 7, times = 100, progress = "none") # calculate and draw M <- 1:5 # minimal number of categories to evaluate p <- c(0.9, .95, 1) # proportion of categories for which minimal m holds d <- calc_probabilities(r, n = N, ms = M, min.props = p) draw_multiple_n_persons_x_times(d)
## simulate prob <- dexp(1:30, .05) # probabilities for categories N <- seq(10, 80, by = 10) # smaple sizes to simulate r <- sim_n_persons_x_times_many_n(prob, n = N, a = 7, times = 100, progress = "none") # calculate and draw M <- 1:5 # minimal number of categories to evaluate p <- c(0.9, .95, 1) # proportion of categories for which minimal m holds d <- calc_probabilities(r, n = N, ms = M, min.props = p) draw_multiple_n_persons_x_times(d)
Produce graphic for a single sample of n persons
draw_n_person_sample(prob, n, a = 10, ap = rep(1/length(a), length(a)))
draw_n_person_sample(prob, n, a = 10, ap = rep(1/length(a), length(a)))
prob |
Probability to draw a construct from a certain category. |
n |
Number of persons, i.e. grids to be sampled. |
a |
Possible number of attributes sampled from. |
ap |
Attribute probabilities, i.e. for each number of attributes given
in |
Other Plotting: draw_multiple_n_persons_x_times
draw_n_person_sample(dexp(1:30, rate = .05), n = 100, a = 10) draw_n_person_sample(dexp(1:30, rate = .05), n = 100, a = 1:5, ap = 5:1)
draw_n_person_sample(dexp(1:30, rate = .05), n = 100, a = 10) draw_n_person_sample(dexp(1:30, rate = .05), n = 100, a = 1:5, ap = 5:1)
Produce ggplot of percentiles for simulated frequencies
expected_frequencies(r)
expected_frequencies(r)
r |
A dataframe. The result returned from |
Draws a ggplot
Other Utilities: calc_probabilities
,
prob_categories
r <- sim_n_persons_x_times(dexp(1:30, rate = .05), n = 50, a = 5:7, ap = 1:3, 100) expected_frequencies(r)
r <- sim_n_persons_x_times(dexp(1:30, rate = .05), n = 50, a = 5:7, ap = 1:3, 100) expected_frequencies(r)
This function starts the gridsampler shiny app.
gridsampler(display.mode = "auto", launch.browser = getOption("shiny.launch.browser", interactive()))
gridsampler(display.mode = "auto", launch.browser = getOption("shiny.launch.browser", interactive()))
display.mode |
|
launch.browser |
Boolean, set |
## Not run: gridsampler() ## End(Not run)
## Not run: gridsampler() ## End(Not run)
Calculate probability for getting certain proportion of categories with at least m constructs
prob_categories(r, m, min.prop = 1)
prob_categories(r, m, min.prop = 1)
r |
A dataframe. The result returned from |
m |
minimal number of constructs in each category |
min.prop |
Proportion of categores to contain at least m constructs. |
Other Utilities: calc_probabilities
,
expected_frequencies
r <- sim_n_persons_x_times(dexp(1:30, rate = .05), n = 50, a = 5:7, times = 100, progress = "none") prob_categories(r, 4, min.prop = .9)
r <- sim_n_persons_x_times(dexp(1:30, rate = .05), n = 50, a = 5:7, times = 100, progress = "none") prob_categories(r, 4, min.prop = .9)
Function is a simple replicate wrapper around sim_one_person
sim_n_persons(prob, n, a = 10, ap = rep(1/length(a), length(a)))
sim_n_persons(prob, n, a = 10, ap = rep(1/length(a), length(a)))
prob |
Probability to draw a construct from a certain category. |
n |
Number of persons, i.e. grids to be sampled. |
a |
Possible number of attributes sampled from. |
ap |
Attribute probabilities, i.e. for each number of attributes given
in |
Other Simulations: sim_n_persons_x_times_many_n
,
sim_n_persons_x_times
,
sim_one_person
sim_n_persons(dexp(1:30, .05), n = 2, a = 10) sim_n_persons(dexp(1:30, .05), n = 2, a = c(1, 30)) sim_n_persons(dexp(1:30, .05), n = 2, a = c(1, 30), ap = c(1,4)) sim_n_persons(dexp(1:30, .05), n = 2, a = 1:5, ap = c(1,1,2,2,3))
sim_n_persons(dexp(1:30, .05), n = 2, a = 10) sim_n_persons(dexp(1:30, .05), n = 2, a = c(1, 30)) sim_n_persons(dexp(1:30, .05), n = 2, a = c(1, 30), ap = c(1,4)) sim_n_persons(dexp(1:30, .05), n = 2, a = 1:5, ap = c(1,1,2,2,3))
Complete simulation
sim_n_persons_x_times(prob, n, a, ap = rep(1/length(a), length(a)), times = 100, progress = "text")
sim_n_persons_x_times(prob, n, a, ap = rep(1/length(a), length(a)), times = 100, progress = "text")
prob |
Probability to draw a construct from a certain category. Length of vector determines number of categories. |
n |
Number of persons, i.e. grids to sample. |
a |
Number of constructs to be sampled. |
ap |
Probabilities for each number of attributes to be sampled. |
times |
Number of times to repeat each simulation. |
progress |
Type of progress bar shown during simulation. |
Other Simulations: sim_n_persons_x_times_many_n
,
sim_n_persons
, sim_one_person
## Not run: sim_n_persons_x_times(dexp(1:30, .05), n = 2, a = c(1,30), ap = 1:2, times = 100) sim_n_persons_x_times(dexp(1:30, .05), n = 2, a = c(1,30), times = 200, progress = "tk") ## End(Not run)
## Not run: sim_n_persons_x_times(dexp(1:30, .05), n = 2, a = c(1,30), ap = 1:2, times = 100) sim_n_persons_x_times(dexp(1:30, .05), n = 2, a = c(1,30), times = 200, progress = "tk") ## End(Not run)
Creates simulation results for different n. Runs
sim_n_persons_x_times
for different n.
sim_n_persons_x_times_many_n(prob, n = seq(10, 80, by = 10), a = 7, ap = rep(1/length(a), length(a)), times = 100, progress = "text")
sim_n_persons_x_times_many_n(prob, n = seq(10, 80, by = 10), a = 7, ap = rep(1/length(a), length(a)), times = 100, progress = "text")
prob |
Probability to draw a construct from a certain category. Length of vector determines number of categories. |
n |
Number of persons, i.e. grids to sample. |
a |
Number of constructs to be sampled. |
ap |
Probabilities for each number of attributes to be sampled. |
times |
Number of times to repeat each simulation. |
progress |
Type of progress bar shown during simulation. |
A result dataframe.
Other Simulations: sim_n_persons_x_times
,
sim_n_persons
, sim_one_person
## Not run: r <- sim_n_persons_x_times_many_n(dexp(1:30, .05), a = 7, times = 100) r <- sim_n_persons_x_times_many_n(dexp(1:30, .05), a = 5:7, ap = 1:3, times = 100) ## End(Not run)
## Not run: r <- sim_n_persons_x_times_many_n(dexp(1:30, .05), a = 7, times = 100) r <- sim_n_persons_x_times_many_n(dexp(1:30, .05), a = 5:7, ap = 1:3, times = 100) ## End(Not run)
Simulate a single grid
sim_one_person(prob, a = 10)
sim_one_person(prob, a = 10)
prob |
Probability to draw a construct from a certain category. |
a |
Number of constructs to be sampled. |
Other Simulations: sim_n_persons_x_times_many_n
,
sim_n_persons_x_times
,
sim_n_persons
# draw from exponential distribution p <- dexp(1:20, rate = .1) sim_one_person(p, a = 10)
# draw from exponential distribution p <- dexp(1:20, rate = .1) sim_one_person(p, a = 10)