Skip to contents

Appends a prediction and a provenance entry. R does not change the theory in place, so assign the result.

Usage

tf_add_prediction(
  theory,
  id,
  statement,
  type,
  derives_from = NULL,
  diagnostic_vs = NULL,
  severity = NULL,
  test = NULL,
  bounds = NULL,
  claim = NULL
)

Arguments

theory

A theory object (named list).

id

The prediction's identifier.

statement

The claim in words.

type

The form of the claim, one of four. "existence" asserts that an effect or relation exists, without a direction. "directional" asserts a sign or an order, including comparisons, interactions, the invariance of a direction across groups and claims that an effect occurs only when a condition holds. "interval" asserts that a quantity lies in a stated range, the range the theory permits. "point" asserts one value, with the tolerance that measurement requires. The tolerance comes from measurement, and the theory itself permits only the one value.

derives_from, diagnostic_vs

Optional character vectors, stored without names.

severity

Optional declared pre-data severity from 0 to 1. The checklist's risk_severity item reads it, and reads the claim-form rubric's value (tf_severity()) for a prediction that declares none.

test

Optional sampling plan for testing the prediction, a named list of any of n_planned, unit, alpha, sided ("two" or "one"), sesoi and sesoi_scale (the smallest effect of interest and its scale), power or decision_probability with an optional power_lo and power_hi, method, design_ref and justification. tf_preregister() lists it after the hypotheses, and nothing scores it.

bounds

Optional region of the quantity the claim allows, a named list of lower and upper, either of which may be NULL for an open side. tf_post_data_severity() reads it with each test outcome.

claim

Optional machine-readable claim, a named list of kind ("effect" or "association"), the construct ids x and y, an optional given and sign ("positive", "negative", "zero" or "nonzero"), which tf_entailments() reads against the causal graph.

Value

The theory with the prediction added.

Examples

tf_theory("demo-1", "A demonstration theory") |>
  tf_add_prediction("h1", "Arousal raises perceived threat.", "directional",
                    claim = list(kind = "effect", x = "c_arousal", y = "c_threat",
                                 sign = "positive"))
#> $schema_version
#> [1] "1.1"
#> 
#> $id
#> [1] "demo-1"
#> 
#> $title
#> [1] "A demonstration theory"
#> 
#> $maturity
#> [1] "building"
#> 
#> $theory_form
#> [1] "network"
#> 
#> $provenance
#> $provenance[[1]]
#> $provenance[[1]]$step
#> [1] "1"
#> 
#> $provenance[[1]]$action
#> [1] "tf_theory"
#> 
#> $provenance[[1]]$detail
#> [1] "demo-1"
#> 
#> 
#> $provenance[[2]]
#> $provenance[[2]]$step
#> [1] "2"
#> 
#> $provenance[[2]]$action
#> [1] "tf_add_prediction"
#> 
#> $provenance[[2]]$detail
#> [1] "h1"
#> 
#> 
#> 
#> $predictions
#> $predictions[[1]]
#> $predictions[[1]]$id
#> [1] "h1"
#> 
#> $predictions[[1]]$statement
#> [1] "Arousal raises perceived threat."
#> 
#> $predictions[[1]]$type
#> [1] "directional"
#> 
#> $predictions[[1]]$claim
#> $predictions[[1]]$claim$kind
#> [1] "effect"
#> 
#> $predictions[[1]]$claim$x
#> [1] "c_arousal"
#> 
#> $predictions[[1]]$claim$y
#> [1] "c_threat"
#> 
#> $predictions[[1]]$claim$sign
#> [1] "positive"
#> 
#> 
#> 
#> 

# A prediction with the sampling plan of its test.
tf_theory("demo-1", "A demonstration theory") |>
  tf_add_prediction("h1", "The switch cost lies between 20 and 60 ms.", "interval",
                    bounds = list(lower = 20, upper = 60),
                    test = list(n_planned = 48, unit = "participants", alpha = 0.05,
                                sided = "two", power = 0.9))
#> $schema_version
#> [1] "1.1"
#> 
#> $id
#> [1] "demo-1"
#> 
#> $title
#> [1] "A demonstration theory"
#> 
#> $maturity
#> [1] "building"
#> 
#> $theory_form
#> [1] "network"
#> 
#> $provenance
#> $provenance[[1]]
#> $provenance[[1]]$step
#> [1] "1"
#> 
#> $provenance[[1]]$action
#> [1] "tf_theory"
#> 
#> $provenance[[1]]$detail
#> [1] "demo-1"
#> 
#> 
#> $provenance[[2]]
#> $provenance[[2]]$step
#> [1] "2"
#> 
#> $provenance[[2]]$action
#> [1] "tf_add_prediction"
#> 
#> $provenance[[2]]$detail
#> [1] "h1"
#> 
#> 
#> 
#> $predictions
#> $predictions[[1]]
#> $predictions[[1]]$id
#> [1] "h1"
#> 
#> $predictions[[1]]$statement
#> [1] "The switch cost lies between 20 and 60 ms."
#> 
#> $predictions[[1]]$type
#> [1] "interval"
#> 
#> $predictions[[1]]$test
#> $predictions[[1]]$test$n_planned
#> [1] 48
#> 
#> $predictions[[1]]$test$unit
#> [1] "participants"
#> 
#> $predictions[[1]]$test$alpha
#> [1] 0.05
#> 
#> $predictions[[1]]$test$sided
#> [1] "two"
#> 
#> $predictions[[1]]$test$power
#> [1] 0.9
#> 
#> 
#> $predictions[[1]]$bounds
#> $predictions[[1]]$bounds$lower
#> [1] 20
#> 
#> $predictions[[1]]$bounds$upper
#> [1] 60
#> 
#> 
#> 
#>