Adds terms to, or drops them from a linear, generalized linear, generalized additive or nonlinear model.

### Options

`PRINT` = string tokens |
What to print (`model, deviance, summary, estimates, correlations, fittedvalues, accumulated, monitoring` , `confidence` ); default `mode,summ,esti` |
---|---|

`NONLINEAR` = string token |
How to treat nonlinear parameters between groups (`common, separate, unchanged` ); default `unch` |

`CONSTANT` = string token |
How to treat the constant (`estimate` , `omit` , `unchanged` , `ignore` ); default `unch` |

`FACTORIAL` = scalar |
Limit for expansion of model terms; default `*` i.e. that in previous `TERMS` statement |

`POOL` = string token |
Whether to pool ss in accumulated summary between all terms fitted in a linear model (`yes, no` ); default `no` |

`DENOMINATOR` = string token |
Whether to base ratios in accumulated summary on rms from model with smallest residual ss or smallest residual ms (`ss` , `ms);` default `ss` |

`NOMESSAGE` = string tokens |
Which warning messages to suppress (`dispersion` , `leverage` , `residual` , `aliasing` , `marginality` , `vertical` , `df` , `inflation` ); default `*` |

`FPROBABILITY` = string token |
Printing of probabilities for variance and deviance ratios (`yes, no` ); default `no` |

`TPROBABILITY` = string token |
Printing of probabilities for t-statistics (`yes, no` ); default `no` |

`SELECTION` = string tokens |
Statistics to be displayed in the summary of analysis produced by `PRINT=summary` , `seobservations` is relevant only for a Normally distributed response, and `%cv` only for a gamma-distributed response (`%variance` , `%ss` , `adjustedr2` , `r2` , `seobservations` , `dispersion` , `%cv` , `%meandeviance` , `%deviance` , `aic` , `bic` , `sic` ); default `%var` , `seob` if `DIST=normal` , `%cv` if `DIST=gamma` , and `disp` for other distributions |

`PROBABILITY` = scalar |
Probability level for confidence intervals for parameter estimates; default 0.95 |

`AOVDESCRIPTION` = text |
Description for line in accumulated analysis of variance (or deviance) table when `POOL=yes` |

### Parameter

formula |
List of explanatory variates and factors, or model formula |
---|

### Description

`SWITCH`

modifies the current regression model, which may be linear, generalized linear, generalized additive, standard curve or nonlinear. Terms in the specified formula are dropped from the current model if they are already there, or are added to it if they are not. It is best to give a `TERMS`

statement before investigating sequences of models using `SWITCH`

, in order to define a common set of units for the models to be explored. If no model is fitted after the `TERMS`

statement, the current model is taken to be the null model.

If the current model contains a smoothed term (specified e.g. by `SSPLINE`

or `LOESS`

) which is included in the formula specified by the parameter of `SWITCH`

with a different number of degrees of freedom (or with the smoothing parameter set), `SWITCH`

will then refit the smoothed term.

The model fitted by `SWITCH`

will include a constant term if the previous model included one, and will not include one if the previous model did not. You can, however, change this using the `CONSTANT`

option.

The options of `SWITCH`

are the same as those of the `FIT`

directive, but with the extra `NONLINEAR`

option which controls whether separate nonlinear parameters are fitted to different groups when fitting curves, as in `FITCURVE`

.

Options: `PRINT`

, `NONLINEAR`

, `CONSTANT`

, `FACTORIAL`

, `POOL`

, `DENOMINATOR`

, `NOMESSAGE`

, `FPROBABILITY`

, `TPROBABILITY`

, `SELECTION`

, `PROBABILITY`

, `AOVDESCRIPTION`

.

Parameter: unnamed.

### Action with `RESTRICT`

If a `TERMS`

statement was given before fitting the model, any restrictions on the variates or factors in the model will have been implemented then. So any restrictions on vectors involved in the model specified by `SWITCH`

will be ignored. If no `TERMS`

statement has been given and `SWITCH`

introduces new terms into the model, restrictions on the variates or factors in these terms will be taken into account and may cause the units involved in the regression to be redefined.

### See also

Directives: `MODEL`

, `TERMS`

, `FIT`

, `FITCURVE`

, `ADD`

, `DROP`

, `STEP`

, `TRY`

.

Functions: `COMPARISON`

, `POL`

, `REG`

, `LOESS`

, `SSPLINE`

.

Commands for: Regression analysis.

### Example

" Examples 2:3.2, 2:3.2.1-6, 2:3.2.7a-b, 2:3.2.8 " " Multiple linear regression of the heat given out by setting cement on four chemical constituents. Data from Woods, Steinour & Starke (1932); analysed by Draper & Smith (1981) p.629." OPEN '%GENDIR%/Examples/GuidePart2/Cement.dat'; CHANNEL=2 READ [PRINT=data; CHANNEL=2] X[3,1,4,2],%gypsum,Heat " Analyse only those samples with 3.2% gypsum." RESTRICT Heat; %gypsum==3.2 MODEL Heat " Constituents are: X[1] tricalcium aluminate X[2] tricalcium silicate X[3] tetracalcium aluminoferrite X[4] beta-dicalcium silicate " FIT [FPROBABILITY=yes; TPROBABILITY=yes] X[] RDISPLAY [PRINT=accumulated; FPROBABILITY=yes] RKESTIMATES X[]; ESTIMATES=Est[1...4]; SE=se[1...4] PRINT Est[1],se[1],Est[2],se[2],Est[3],se[3],Est[4],se[4]; FIELD=10,8 TERMS [PRINT=correlation] X[] ADD [PRINT=deviance,estimates; TPROBABILITY=yes] X[1,2,4] DROP [PRINT=deviance,estimates; TPROBABILITY=yes] X[4] SWITCH [PRINT=estimates,accumulated; FPROBABILITY=yes;\ TPROBABILITY=yes] X[2,4] TRY X[2,3] FIT [FPROBABILITY=yes; TPROBABILITY=yes] X[] RWALD FIT [PRINT=*] X[1] STEP [INRATIO=4; OUTRATIO=4; FPROBABILITY=yes; TPROBABILITY=yes] X[1...4] TERMS X[] STEP [PRINT=changes; INRATIO=4; OUTRATIO=4; MAXCYCLE=10] X[] RDISPLAY [FPROBABILITY=yes; TPROBABILITY=yes] RSEARCH [METHOD=allpossible] X[1...4] CLOSE 2