# What is a “symbolically nested” model?

survey::anova.svyglm is a method of anova() that does model comparison for survey data. The details section of the documentation makes a distinction between "nested" and "symbolically nested" models in the discussion of likelihood ratio tests:

"Typical examples of models that are nested but not symbolically nested are linear and spline models for a continuous covariate or linear and saturated models for a factor."

Can someone please explain this distinction a bit more?

Two models are symbolically nested if you can tell they are nested just by looking at the model formula, without knowing what any variables or functions do

The example on the anova.svyglm web page is

I(sch.wide=="Yes")~ell+meals+mobility
I(sch.wide=="Yes")~ell+meals+mobility+as.numeric(stype)
I(sch.wide=="Yes")~ell+meals+mobility+stype


The second and third models are symbolically nested in the first model; they consist of all the terms in the first model, plus a new term.

The third model is not symbolically nested in the second; you'd need to know what as.numeric did to know that they were nested. Even more so, if you'd defined a new variable stype_n=as.numeric(type) and the second model formula was

I(sch.wide=="Yes")~ell+meals+mobility+stype_n


you couldn't tell without looking at the variable definition or variable values that the models were nested.

Another important example of models that aren't symbolically nested is linear and regression spline models in a continuous variable: the regression spline is nested in the linear model, but you need to know quite a bit about the definitions to know this.

The reason for the distinction is that for symbolically nested models it is easy to decompose the larger model's design matrix into a part that's the same as the smaller model and a separate part, just by knowing how model.matrix works. If they aren't symbolically nested, it's necessary to use something like QR decomposition and to have a threshold for treating columns as linearly dependent. The code is more complicated, and more numerically sensitive.

The autour of the survey package Thomas Lumley has written a book using the package, but I cannot find symbolical nesting mentioned there. The docu page you cites also says

If the models are symbolically nested, so that the relevant parameters can be identified just by manipulating the model formulas, anova is equivalent to regTermTest.

so this is probably not a statistical concept, but programmatic concept. Is is about the possibiliy of simply proving nestedness from the model formula. The docu says in continuation

If the models are nested but not symbolically nested, more computation using the design matrices is needed to determine the projection matrix on to the parameters being tested.

I cannot find information about this on the web, so maybe (if what I have written is not enough) you could ask on R-help.