Skip to contents

statsguider is built for a narrow question:

“I already have a data.frame. Which simple statistical test matches this design, and can I run it immediately?”

The package keeps the input contract small:

  • data
  • outcome
  • group
  • id when paired or repeated data are used
  • a few choice-style arguments such as goal, outcome_type, paired, and run

First recommendation

Create a small table and ask for a recommendation.

dat <- data.frame(
  group = c(rep("control", 8), rep("treated", 8)),
  value = c(5.0, 5.2, 4.8, 5.1, 5.3, 4.9, 5.0, 5.4,
            6.1, 6.0, 5.8, 6.2, 6.3, 5.9, 6.1, 6.0)
)

select_test(
  data = dat,
  outcome = "value",
  group = "group",
  goal = "difference",
  outcome_type = "continuous",
  paired = "no",
  repeated = "no",
  adjust = "no",
  normality = "auto",
  run = "recommend"
)
#> statsguider decision
#> - action: recommend
#> - method: Welch t-test
#> - alternative: Mann-Whitney U test
#> - reason: The design is an independent two-group continuous comparison with acceptable normality.
#> - next step: Run the Welch t-test.
#> - notes:
#>   * Normality was checked automatically and classified as `yes`.

Run the test

When the branch is acceptable, switch to run = "run".

select_test(
  data = dat,
  outcome = "value",
  group = "group",
  goal = "difference",
  outcome_type = "continuous",
  paired = "no",
  repeated = "no",
  adjust = "no",
  normality = "auto",
  run = "run"
)
#> statsguider result
#> - method: Welch t-test
#> - reason: The design is an independent two-group continuous comparison with acceptable normality.
#> - summary: Welch t-test was selected for a continuous outcome with 2 groups.
#> 
#> 
#>  Welch Two Sample t-test
#> 
#> data:  value by group
#> t = -10.52, df = 13.285, p-value = 8.141e-08
#> alternative hypothesis: true difference in means between group control and group treated is not equal to 0
#> 95 percent confidence interval:
#>  -1.1597234 -0.7652766
#> sample estimates:
#> mean in group control mean in group treated 
#>                5.0875                6.0500

Validate before execution

Use check_design() when you want to inspect the design contract explicitly.

check_design(
  data = dat,
  outcome = "value",
  group = "group",
  goal = "difference",
  outcome_type = "continuous",
  paired = "no",
  repeated = "no",
  adjust = "no"
)
#> $ok
#> [1] TRUE
#> 
#> $issues
#> character(0)
#> 
#> $warnings
#> character(0)
#> 
#> $inputs
#> $inputs$goal
#> [1] "difference"
#> 
#> $inputs$outcome_type
#> [1] "continuous"
#> 
#> $inputs$group_count
#> [1] "2"
#> 
#> $inputs$paired
#> [1] "no"
#> 
#> $inputs$repeated
#> [1] "no"
#> 
#> $inputs$adjust
#> [1] "no"

What happens outside the simple branch

The package redirects rather than forcing a wrong analysis.

recommend_test(
  data = dat,
  outcome = "value",
  group = "group",
  goal = "adjusted_effect",
  outcome_type = "continuous",
  paired = "no",
  repeated = "no",
  adjust = "yes"
)
#> statsguider decision
#> - action: redirect
#> - reason: This question requires adjusted effect estimation rather than a simple unadjusted test.
#> - next step: Move to regression or mixed-effects models.
#> - notes:
#>   * Adjusted analyses should move to regression or mixed-effects models.