Skip to contents

test_pdiff is suitable for testing a hypothesis about a difference in proportions between two conditions with a categorical outcome variable. It can test hypotheses for both independent and paired designs.

Usage

test_pdiff(estimate, rope = c(0, 0), output_html = FALSE)

Arguments

estimate
  • An esci_estimate object generated by an estimate_pdiff_ function

rope
  • A two-element vector defining the Region of Practical Equivalence (ROPE). Specify c(0, 0) to test a point null of exactly 0. Specify any two ascending values between -1 and 1 to test an interval null (e.g. c(-.25, .25) to test the hypothesis that the difference in proportion is between -.25 and .25).

output_html
  • TRUE to return results in HTML; FALSE (default) to return standard output

Value

Returns a list with 1-2 data frames

  • point_null - always returned

    • test_type - 'Nil hypothesis test', meaning a test against H0 = 0

    • outcome_variable_name - Name of the outcome variable

    • effect - Label for the effect being tested

    • null_words - Express the null in words

    • confidence - Confidence level, integer (95 for 95%, etc.)

    • LL - Lower boundary of the confidence% CI for the effect

    • UL - Upper boundary of the confidence% CI for the effect

    • CI - Character representation of the CI for the effect

    • CI_compare - Text description of relation between CI and null

    • t - If applicable, t value for hypothesis test

    • df - If applicable, degrees of freedom for hypothesis test

    • p - If applicable, p value for hypothesis test

    • p_result - Text representation of p value obtained

    • null_decision - Text represention of the decision for the null

    • conclusion - Text representation of conclusion to draw

    • significant - TRUE/FALSE if significant at alpha = 1-CI

  • interval_null - returned only if an interval null is specified

    • test_type - 'Practical significance test', meaning a test against an interval null

    • outcome_variable_name -

    • effect - Name of the outcome variable

    • rope - Test representation of null interval

    • confidence - Confidence level, integer (95 for 95%, etc.)

    • CI - Character representation of the CI for the effect

    • rope_compare - Text description of relation between CI and null interval

    • p_result - Text representation of p value obtained

    • conclusion - Text representation of conclusion to draw

    • significant - TRUE/FALSE if significant at alpha = 1-CI

Details

This function can be passed an esci_estimate object generated by estimate_pdiff_one(), estimate_pdiff_two(), estimate_pdiff_paired(), or estimate_pdiff_ind_contrast().

It can test hypotheses about a specific value for the difference (a point null) or about a range of values (an interval null)

Examples

estimate <- estimate_pdiff_two(
  comparison_cases = 10,
  comparison_n = 20,
  reference_cases = 78,
  reference_n = 252,
  grouping_variable_levels = c("Original", "Replication"),
  conf_level = 0.95
)

# Test against null of exactly
test_pdiff(estimate)
#> $properties
#> $properties$effect_size_name
#> [1] "P"
#> 
#> $properties$alpha
#> [1] 0.05
#> 
#> $properties$interval_null
#> [1] FALSE
#> 
#> $properties$rope
#> [1] 0 0
#> 
#> $properties$rope_units
#> [1] "raw"
#> 
#> 
#> $point_null
#>             test_type outcome_variable_name case_label                 effect
#> 1 Nil Hypothesis Test   My outcome variable P_Affected Replication ‒ Original
#>   null_words confidence          LL        UL                              CI
#> 1       0.00         95 -0.02757339 0.4055261 95% CI [-0.02757339, 0.4055261]
#>                CI_compare        t df          p p_result      null_decision
#> 1 The 95% CI contains H_0 1.710401 NA 0.08719178 p ≥ 0.05 Fail to reject H_0
#>                                              conclusion significant
#> 1 At α = 0.05, 0.00 remains a plausible value of Π_diff       FALSE
#> 

# Test against null of (-0.1, 0.1)
test_pdiff(estimate, rope = c(-0.1, 0.1))
#> $properties
#> $properties$effect_size_name
#> [1] "P"
#> 
#> $properties$alpha
#> [1] 0.05
#> 
#> $properties$interval_null
#> [1] TRUE
#> 
#> $properties$rope
#> [1] -0.1  0.1
#> 
#> $properties$rope_units
#> [1] "raw"
#> 
#> 
#> $point_null
#>             test_type outcome_variable_name case_label                 effect
#> 1 Nil Hypothesis Test   My outcome variable P_Affected Replication ‒ Original
#>   null_words confidence          LL        UL                              CI
#> 1       0.00         95 -0.02757339 0.4055261 95% CI [-0.02757339, 0.4055261]
#>                CI_compare        t df          p p_result      null_decision
#> 1 The 95% CI contains H_0 1.710401 NA 0.08719178 p ≥ 0.05 Fail to reject H_0
#>                                              conclusion significant
#> 1 At α = 0.05, 0.00 remains a plausible value of Π_diff       FALSE
#> 
#> $interval_null
#>                     test_type outcome_variable_name case_label
#> 1 Practical significance test   My outcome variable P_Affected
#>                   effect          rope confidence
#> 1 Replication ‒ Original (-0.10, 0.10)         95
#>                                                                 CI
#> 1 95% CI [-0.02757339, 0.4055261]\n90% CI [0.007242087, 0.3707107]
#>                               rope_compare p_result
#> 1 95% CI has values inside and outside H_0 p ≥ 0.05
#>                                                      conclusion significant
#> 1 At α = 0.05, not clear if Π_diff is substantive or negligible       FALSE
#>