Known Smooth and Threshold Interactions for Model Comparison
binwise_interaction.RdA reproducible simulated dataset with two focal variables, one control, two continuous outcomes, and a binary outcome. The generating rules illustrate different consequences of categorization.
Usage
data(binwise_interaction)Format
A data frame with 1200 rows and these columns:
- id
Integer row identifier.
- x, z
Independent uniform draws between -2 and 2.
- control
Independent standard normal draws.
- expected_outcome
1 + 0.8*x - 0.5*z + 0.9*x*z + 0.4*control.- outcome
The smooth expectation plus independent normal noise with SD 1.2.
- expected_threshold
1 + 1.8*(x > 0) - 0.7*z + 1.1*(x > 0)*z + 0.4*control.- threshold_outcome
The threshold expectation plus independent normal noise with SD 1.2.
- probability
Inverse logit of
-0.4 + 0.6*x - 0.4*z + 0.7*x*z + 0.3*control.- binary_outcome
A Bernoulli draw at the corresponding probability.
Details
The source generator uses seed 9388 and appends this simulation after the five
descriptive examples documented in binwise_examples; those datasets are
unchanged. All rows are simulated, with no research or personal data.
The continuous product term matches the smooth expectation's form. The zero
threshold matches the other continuous outcome's form. This intentional design
does not imply that either form is universally preferable. Compare model-fit
criteria within the same outcome and sample, not across the different outcomes.
The known expectations and probability are teaching aids, not model controls.
Examples
data(binwise_interaction)
head(binwise_interaction)
#> id x z control outcome threshold_outcome
#> 1 1 1.7978115 1.8862030 -0.8713074 3.7780834 1.0156904
#> 2 2 0.1050479 -0.6126716 1.1711089 2.1869512 2.2784124
#> 3 3 1.2818941 -0.4440960 -1.7554969 1.9051293 0.3705449
#> 4 4 1.4422249 0.7202922 -0.5464465 2.2306950 2.6437256
#> 5 5 -0.5534924 -1.4394725 -0.4638422 0.7094214 2.9818015
#> 6 6 0.6399382 0.4012683 -0.6023382 -0.4867704 0.5057122
#> binary_outcome expected_outcome expected_threshold probability
#> 1 1 4.198558 3.205958 0.8845804
#> 2 1 1.800894 3.023375 0.5533902
#> 3 0 1.033009 1.920163 0.4065194
#> 4 0 2.509996 2.869538 0.6770965
#> 5 0 1.808469 1.822094 0.5651910
#> 6 0 1.301489 2.719572 0.4557424