fsrmrmr
statistics: idx = fsrmrmr (Tbl, ResponseVarName)
statistics: idx = fsrmrmr (Tbl, formula)
statistics: idx = fsrmrmr (Tbl, Y)
statistics: idx = fsrmrmr (X, Y)
statistics: idx = fsrmrmr (…, name, value)
statistics: [idx, scores] = fsrmrmr (…)
Rank the predictors for regression by minimum redundancy and maximum relevance.
idx = fsrmrmr (X, Y) ranks the predictors, the
columns of the matrix X, by how much they tell about the response
Y and how little they repeat each other, both measured by mutual
information. idx is a row vector of column indices, from the most
important predictor to the least.
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 value per row of X. An observation whose response is NaN is left out.
idx = fsrmrmr (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 = fsrmrmr (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 = fsrmrmr (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] = fsrmrmr (…) also returns the score
of each predictor, a row vector in the order of the predictors. The score
is the value on which the predictor was chosen, as described below, so a
larger score marks a more important predictor when it was chosen, but the
scores need not decrease along idx.
The relevance of a predictor is its mutual information with the response, and its redundancy the mean of its mutual information with each predictor already ranked. The predictors are ranked in six steps, after Ding and Peng:
Predictors of equal value keep the order of the columns at every step.
Mutual information is in nats. Between two categorical predictors it is the plain estimate from their table of weighted counts. Where one variable is continuous, as the response always is, it is the adaptive partitioning estimate of Darbellay and Vajda. The continuous variables are replaced by their ranks, so the estimate does not change under an increasing transformation of either. The observations are divided into rectangular cells, starting from a single cell, and a cell is split into 2 by 2 cells while it shows dependence. A cell is tested by dividing it at the quantiles of the strips it spans into 2 by 2 and into 4 by 4 parts and comparing the weighted count of each part with the count the strips predict, by a chi-square statistic with 3 and 15 degrees of freedom at the 3% level; the cell stays whole only when neither statistic is significant. The estimate is then the sum over the cells of P(A,B) log (P(A,B) / (P(A) P(B))), P(A) and P(B) being the shares of the strips the cell spans. A categorical predictor is not divided: its categories are its strips, and the cells along each category are tested and split on their own, with 1 and 3 degrees of freedom. Equal values are never parted, the quantiles moving to the nearest change of value.
Each estimate uses the observations known for both of its variables, their weights scaled to sum to the number of those observations; the quantiles and the counts are taken by weight.
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. |
'UseMissing' | false, the default, to estimate
each mutual information on the observations known for both variables, or
true to use every observation, the missing values of a categorical
predictor forming one more category and those of a continuous predictor
one more strip, which is never divided but whose cells are split along the
other variable as the cells of a category are. MATLAB R2024a documents
this option but ignores it in fsrmrmr, scoring every predictor alike
either way; Octave does what it documents. |
'Verbose' | A nonnegative integer. The default, 0, prints nothing; 1 or more prints the time taken by the mutual information and by the ranking. |
'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.
MATLAB documents the same six steps and the same estimator, but R2024a follows neither exactly. Its scores depart from the steps once redundancy enters. Its estimator does not test a cell on 4 by 4 parts, so it scores 0 a categorical predictor whose levels alternate in equal blocks along the response, which this estimate finds, and it finds less dependence than this estimate on some continuous predictors. It first cuts a continuous variable into 256 bins, which is not done here, and it ranks the predictors of zero relevance in random order.
References:
See also: fscmrmr, fsrftest, relieff, sequentialfs
Source Code: fsrmrmr