fsrftest
statistics: idx = fsrftest (Tbl, ResponseVarName)
statistics: idx = fsrftest (Tbl, formula)
statistics: idx = fsrftest (Tbl, Y)
statistics: idx = fsrftest (X, Y)
statistics: idx = fsrftest (…, name, value)
statistics: [idx, scores] = fsrftest (…)
Rank the predictors for regression with F-tests.
idx = fsrftest (X, Y) tests each predictor, a
column of the matrix X, with a one-way analysis of variance: whether
the response Y has the same mean in every group of observations the
predictor forms. It ranks the predictors by the result. idx is a row
vector of column indices, from the most important predictor to the least;
predictors of equal score keep their order.
X is a real matrix of type double or single with one row per observation, and Y a real vector of type double or single with one response per row of X.
idx = fsrftest (Tbl, ResponseVarName) takes the
predictors and the response from the table Tbl: ResponseVarName
names the variable holding the response and every other variable is a
predictor. idx = fsrftest (Tbl, formula) names
them with a model formula instead, 'Y ~ x1 + x2', which holds main
effects only, and ranks only the predictors it names, idx indexing
them in the order the table holds them. idx = fsrftest
(Tbl, Y) takes the predictors from the table and the response
from Y. A logical, categorical, text or string variable of the table
is a categorical predictor; an ordinal categorical one is continuous, its
categories in their order.
[idx, scores] = fsrftest (…) also returns the
score of each predictor, a row vector of type double in the order of the
predictors, so that scores(idx) is in decreasing order.
The score is -log (p), p being the p-value of the predictor’s
F-test, so a larger score marks a more important predictor; it is
Inf where p is 0. A predictor that forms a single group, or
as many groups as observations, scores 0, and so does every predictor when
the response is constant.
A continuous predictor is first binned. Its n known values are
sorted, the upper edge of bin k is the value at position
ceil (k * n / NumBins), and a value goes to the
first bin whose edge it does not exceed. The bins so hold equal numbers of
observations as nearly as the ties allow, the first ones taking any
remainder, and equal values always share a bin, which may leave fewer bins
than asked for. A categorical predictor takes its categories as they
are. The F-test weighs each observation by its weight, scaling the
weights not mattering.
Each predictor is tested on the observations it is known for. An observation whose response is missing is left out of every test.
The following Name-Value pairs are supported:
| Name | Value |
|---|---|
'CategoricalPredictors' | The categorical predictors: a
vector of their indices, a logical vector with one value per predictor, or
'all'. With a table they are added to those the table makes
categorical, and they may also be named. The default is none for a matrix. |
'NumBins' | The number of bins of a continuous predictor, a positive integer. The default is 10. |
'UseMissing' | false, the default, to test each
predictor on the observations it is known for, or true to test it
on every observation, the missing values of a categorical predictor forming
one more category and those of a continuous predictor one more bin. MATLAB
R2024a and R2026b document this option but ignore it in fsrftest,
scoring every predictor alike either way; Octave does what they document. |
'Weights' | The observation weights, a nonnegative finite vector of type double or single with one value per row, or with a table the name of one of its variables, which is then no predictor. The default is equal weights. |
The option names are not case sensitive but must be given in full. With a matrix, the categorical predictors cannot be named, the predictors having no names, as in MATLAB. The test is computed in double precision whatever the type of the data; MATLAB R2024a gives a different score for a response of type single than for the same values as double, which Octave does not.
See also: fscchi2, relieff, sequentialfs, anova1
Source Code: fsrftest