
Residual Diagnostics for MARS Models
residual_diagnostics.RdCompute a compact residual-diagnostics summary that works across univariate,
multivariate, and multilevel mars fits.
Examples
# \donttest{
fit <- mars(
data = teacher_expectancy,
studyID = "study",
effectID = NULL,
sample_size = NULL,
formula = yi ~ 1,
variance = "vi",
varcov_type = "univariate",
structure = "univariate"
)
residual_diagnostics(fit)
#> $structure
#> [1] "univariate"
#>
#> $residuals
#> index fitted raw pearson studentized whitened cluster
#> 1 1 0.08370128 -0.05370128 -0.28946078 -0.30137140 -0.28946078 1
#> 2 2 0.08370128 0.03629872 0.18055190 0.18682016 0.18055190 2
#> 3 3 0.08370128 -0.22370128 -1.03496293 -1.06582956 -1.03496293 3
#> 4 4 0.08370128 1.09629872 2.75875178 2.78234449 2.75875178 4
#> 5 5 0.08370128 0.17629872 0.44777270 0.45167461 0.44777270 5
#> 6 6 0.08370128 -0.14370128 -0.83782168 -0.87858944 -0.83782168 6
#> 7 7 0.08370128 -0.10370128 -0.60460966 -0.63402950 -0.60460966 7
#> 8 8 0.08370128 -0.40370128 -1.55709909 -1.58893713 -1.55709909 8
#> 9 9 0.08370128 0.18629872 0.87129387 0.89787390 0.87129387 9
#> 10 10 0.08370128 0.71629872 2.50419908 2.54603515 2.50419908 10
#> 11 11 0.08370128 0.45629872 1.37567775 1.39265980 1.37567775 11
#> 12 12 0.08370128 0.09629872 0.36788925 0.37526445 0.36788925 12
#> 13 13 0.08370128 -0.10370128 -0.32419581 -0.32850505 -0.32419581 13
#> 14 14 0.08370128 0.14629872 0.45603076 0.46205632 0.45603076 14
#> 15 15 0.08370128 -0.26370128 -1.25545943 -1.29521460 -1.25545943 15
#> 16 16 0.08370128 -0.14370128 -0.66483973 -0.68466785 -0.66483973 16
#> 17 17 0.08370128 0.21629872 1.10786534 1.14877819 1.10786534 17
#> 18 18 0.08370128 -0.01370128 -0.08244465 -0.08673857 -0.08244465 18
#> 19 19 0.08370128 -0.15370128 -0.69351470 -0.71314407 -0.69351470 19
#>
#> $summary
#> n n_finite_raw mean_raw sd_raw rmse mae q_pearson
#> 1 19 19 0.07998293 0.3588749 0.3583434 0.2491422 25.59518
#> mean_abs_studentized max_abs_studentized prop_abs_studentized_gt2
#> 1 0.9379229 2.782344 0.1052632
#> prop_abs_studentized_gt3
#> 1 0
#>
#> $normality
#> test n_tested statistic p_value
#> 1 shapiro_wilk_whitened 19 0.9380569 0.2432093
#>
#> $heteroscedasticity
#> n corr_abs_raw_fitted slope p_value
#> 1 19 NA NA NA
#>
#> $by_cluster
#> study n mean_raw rmse mean_abs_studentized q_pearson
#> 1 1 1 -0.05370128 0.05370128 0.30137140 0.083787544
#> 2 2 1 0.03629872 0.03629872 0.18682016 0.032598988
#> 3 3 1 -0.22370128 0.22370128 1.06582956 1.071148261
#> 4 4 1 1.09629872 1.09629872 2.78234449 7.610711388
#> 5 5 1 0.17629872 0.17629872 0.45167461 0.200500395
#> 6 6 1 -0.14370128 0.14370128 0.87858944 0.701945173
#> 7 7 1 -0.10370128 0.10370128 0.63402950 0.365552838
#> 8 8 1 -0.40370128 0.40370128 1.58893713 2.424557588
#> 9 9 1 0.18629872 0.18629872 0.89787390 0.759153003
#> 10 10 1 0.71629872 0.71629872 2.54603515 6.271013054
#> 11 11 1 0.45629872 0.45629872 1.39265980 1.892489261
#> 12 12 1 0.09629872 0.09629872 0.37526445 0.135342500
#> 13 13 1 -0.10370128 0.10370128 0.32850505 0.105102923
#> 14 14 1 0.14629872 0.14629872 0.46205632 0.207964056
#> 15 15 1 -0.26370128 0.26370128 1.29521460 1.576178375
#> 16 16 1 -0.14370128 0.14370128 0.68466785 0.442011867
#> 17 17 1 0.21629872 0.21629872 1.14877819 1.227365622
#> 18 18 1 -0.01370128 0.01370128 0.08673857 0.006797121
#> 19 19 1 -0.15370128 0.15370128 0.71314407 0.480962640
#>
#> $by_outcome
#> NULL
#>
#> attr(,"class")
#> [1] "mars_residual_diagnostics"
# }