
Scale-Location Models with MARS
mars authors
2026-11-20
Scale-Location-Models.RmdScale-location models let the fixed-effect formula describe the mean
effect while scale_formula describes heterogeneity on the
log scale. This vignette is intentionally small: it shows the core
workflow and returned objects without building a full applied
analysis.
Univariate Scale-Location Model
The bundled school data contain one effect-size estimate
and sampling variance per row. In the model below,
effect ~ year is the location model and
scale_formula = ~ year lets the between-study standard
deviation vary with year.
fit_uni_scale <- mars(
data = school,
formula = effect ~ year,
scale_formula = ~ year,
studyID = "study",
variance = "var",
varcov_type = "univariate",
structure = "univariate",
estimation_method = "MLE"
)
#> Warning in return_estimates(q_f = q_f, q_r = q_r, estimated_pars =
#> optim_values[["par"]], : Hessian inversion failed: Hessian is singular,
#> indefinite, or numerically unidentified.
summary(fit_uni_scale)
#> Results generated with MARS:v 0.6.0.8
#> Friday, November 20, 2026
#>
#> Model Type:
#> univariate
#>
#> Estimation Method:
#> Maximum Likelihood
#>
#> Coefficient covariance: gls
#> Optimizer convergence code: 0
#>
#>
#> Model Formula:
#> effect ~ year
#>
#> Scale Formula:
#> ~year
#>
#> Data Summary:
#> Number of Effect Sizes: 56
#> Number of Fixed Effects: 2
#> Number of Random Effects: 3
#>
#> Random Components:
#> term var SD
#> min 0.09494 0.3081
#> median 0.09556 0.3091
#> max 0.09766 0.3125
#>
#> Fixed Effects Estimates:
#> attribute estimate SE z_test p_value lower upper
#> (Intercept) -10.318277 9.073329 -1.137 0.2555 -28.101674 7.46512
#> year 0.005249 0.004559 1.151 0.2496 -0.003687 0.01419
#>
#>
#> Scale Effects Estimates:
#> attribute estimate
#> (Intercept) -5.920e-07
#> year -1.177e-03
#>
#> Model Fit Statistics:
#> logLik Dev AIC BIC AICc
#> -19.43 48.86 46.86 54.96 49.2
#>
#> Q Error: 550.26 (54), p < 0.0001
#>
#> I2 (General):
#> term values
#> min 95.03
#> median 95.06
#> max 95.16
#>
#>
#> Residual Diagnostics:
#> Diagnostic Value
#> Observations 56
#> Finite raw residuals 56
#> Mean raw residual -0.005473
#> SD of raw residuals 0.3192
#> Root mean squared residual 0.3164
#> Mean absolute residual 0.2403
#> Sum of squared Pearson residuals 48.84
#> Mean |studentized residual| 0.7131
#> Maximum |studentized residual| 3.208
#> Proportion |studentized residual| > 2 0.05357
#> Proportion |studentized residual| > 3 0.01786
#>
#> Normality screen (Shapiro-Wilk, whitened residuals):
#> N W p-value
#> 56 0.9158 0.0008219
#>
#> Heteroscedasticity screen (|raw residual| vs fitted):
#> N Correlation Slope p-value
#> 56 0.1329 0.517 0.3289The fitted object stores the scale coefficients and the implied
heterogeneity values. For univariate scale-location models,
est_values$Tau has one value per effect-size row.
fit_uni_scale$scale_coefficients
#> attribute estimate
#> 1 (Intercept) -5.920062e-07
#> 2 year -1.177258e-03
head(fit_uni_scale$est_values$Tau)
#> [1] 0.09766011 0.09766011 0.09766011 0.09766011 0.09617687 0.09617687
range(fit_uni_scale$est_values$Tau)
#> [1] 0.09493942 0.09766011The coefficients are on the log-heterogeneity scale. A simple way to
inspect the fitted pattern is to plot Tau against the scale
predictor.
plot(
school$year,
fit_uni_scale$est_values$Tau,
xlab = "Year",
ylab = "Fitted heterogeneity",
pch = 19,
col = "steelblue"
)
Multilevel Scale-Location Model
For multilevel models, scale_formula can be a single
one-sided formula applied to each random-effect component. Here the
scale side is intercept-only, so each component has its own baseline
heterogeneity.
fit_ml_scale <- mars(
data = school,
formula = effect ~ 1 + (1 | district/study),
scale_formula = ~ 1,
studyID = "district",
variance = "var",
varcov_type = "multilevel",
structure = "multilevel",
estimation_method = "MLE"
)
summary(fit_ml_scale)
#> Results generated with MARS:v 0.6.0.8
#> Friday, November 20, 2026
#>
#> Model Type:
#> multilevel
#>
#> Estimation Method:
#> Maximum Likelihood
#>
#> Coefficient covariance: gls
#> Optimizer convergence code: 0
#>
#>
#> Model Formula:
#> effect ~ 1 + (1 | district/study)
#>
#> Scale Formula:
#> ~1
#>
#> Data Summary:
#> Number of Effect Sizes: 56
#> Number of Fixed Effects: 1
#> Number of Random Effects: 2
#>
#> Random Data Summary:
#> Number unique district: 11
#> Number unique study: 56
#>
#> Random Components:
#> term var SD
#> district 0.05774 0.2403
#> study 0.03286 0.1813
#>
#> Fixed Effects Estimates:
#> attribute estimate SE z_test p_value lower upper
#> (Intercept) 0.1845 0.08048 2.292 0.02191 0.02672 0.3422
#>
#>
#> Scale Effects Estimates:
#> attribute component estimate SE z_test p_value lower upper
#> (Intercept) district -2.852 0.5324 -5.356 8.499e-08 -3.895 -1.808
#> (Intercept) study -3.415 0.3390 -10.076 7.044e-24 -4.080 -2.751
#>
#> Model Fit Statistics:
#> logLik Dev AIC BIC AICc
#> -8.395 24.79 22.79 28.87 24.5
#>
#> Q Error: 578.864 (55), p < 0.0001
#>
#> I2 (General):
#> names values
#> district 92.11
#> study 86.92
#>
#> I2 (Jackson): 98.69619
#> I2 (Between): 86.37255
#>
#> Residual Diagnostics:
#> Diagnostic Value
#> Observations 56
#> Finite raw residuals 56
#> Mean raw residual -0.06446
#> SD of raw residuals 0.3258
#> Root mean squared residual 0.3293
#> Mean absolute residual 0.2632
#> Sum of squared Pearson residuals 96.8
#> Mean |studentized residual| 1.065
#> Maximum |studentized residual| 4.196
#> Proportion |studentized residual| > 2 0.1071
#> Proportion |studentized residual| > 3 0.03571
#>
#> Normality screen (Shapiro-Wilk, whitened residuals):
#> N W p-value
#> 56 0.9555 0.03766The returned scale table identifies which random-effect component
each scale coefficient belongs to. Tau_by_study gives the
fitted component-specific heterogeneity values by top-level cluster.
fit_ml_scale$scale_coefficients
#> attribute component estimate
#> 1 (Intercept) district -2.851851
#> 2 (Intercept) study -3.415368
head(fit_ml_scale$est_values$Tau_by_study)
#> district study
#> [1,] 0.05773737 0.03286431
#> [2,] 0.05773737 0.03286431
#> [3,] 0.05773737 0.03286431
#> [4,] 0.05773737 0.03286431
#> [5,] 0.05773737 0.03286431
#> [6,] 0.05773737 0.03286431Component-Specific Scale Formulas
Multilevel scale models also accept a named list of formulas, one per
random-effect component. Scale predictors must be invariant within the
top-level studyID cluster. The code below creates a
district-level version of year and uses it only for the
study component.
school2 <- school
school2$district_year <- ave(school2$year, school2$district, FUN = min)
fit_component_scale <- mars(
data = school2,
formula = effect ~ 1 + (1 | district/study),
scale_formula = list(
district = ~ 1,
study = ~ 1 + district_year
),
studyID = "district",
variance = "var",
varcov_type = "multilevel",
structure = "multilevel",
estimation_method = "MLE"
)
fit_component_scale$scale_coefficients
head(fit_component_scale$est_values$Tau_by_study)In short, scale_formula is the scale-side analogue of
the location formula: use the main formula for average
effects and scale_formula for modeled heterogeneity.