Variable Lists (KNN command)
The command line variable lists specify the dependent variable, any categorical predictors (also known as factors), and any scale predictors (also known as covariates).
Dependent Variable
- An optional dependent variable must be the first
specification on the
KNN
command. - The dependent variable may be followed by the measurement
level specification, which contains, in parentheses, the
MLEVEL
keyword followed by an equals sign and thenS
for scale,O
for ordinal, orN
for nominal.KNN
treats ordinal and nominal dependent variables equivalently as categorical. - If a measurement level is specified, then it temporarily overrides a dependent variable's setting in the data dictionary.
- If no measurement level is specified, then
KNN
defaults to the dictionary setting. - If a measurement level is not specified and no setting is recorded in the data dictionary, then a numeric variable is treated as scale and a string variable is treated as categorical.
- Dependent variables can be numeric or string.
- A string variable may be defined as ordinal or nominal only.
Predictor Variables
- The names of the factors, if any, must be preceded
by the keyword
BY
. - If keyword
BY
is specified with no factors, then a warning is issued andBY
is ignored. - The names of the covariates, if any, must be preceded
by the keyword
WITH
. - If keyword
WITH
is specified with no covariates, then a warning is issued andWITH
is ignored. - A dependent variable may not be specified within a factor or covariate list. If a dependent variable is specified within one of these lists, then an error is issued.
- All variables specified within a factor or covariate list must be unique. If duplicate variables are specified within a list, then the duplicates are ignored.
- If duplicate variables are specified across the factor and covariate lists, then an error is issued.
- Factor variables can be numeric or string.
- Covariates must be numeric.
- At least one predictor must be specified.