# Does the stepwisefit function in MATLAB handle correlation between the factors?

I have been told to run a factor analysis using the stepwisefit function in MATLAB.

Basically, this function helps you fit a model composed of $T$ factors $F=(f_1, ... , f_T)$ each of which have $N$ values with a target vector $y$ with the same length.

I know for a fact that my factors are correlated, and I was wondering if this function was assuming that the factors are uncorrelated or not...

Should I still use this function or, if it's not the case, which function/method should I choose to perform my analysis?

-

Strange. I don't see any reference to factor analysis under the link. It reads that `stepwisefit` is stepwise regression analysis – ttnphns Jul 14 '12 at 14:30
Maybe my wording is wrong, I understand factor analysis as a multiple regression over different factors. – SRKX Jul 14 '12 at 14:31
I can't know what you might intend. You can see definition of "factor analysis" by pointing on the tag (or read in Wikipedia). Does its meaning fit your case? – ttnphns Jul 14 '12 at 14:35
Yes, it absolutely does. Basically, I have a lot of underlying factors and I would like to know which of them are really meaningful. I would then like to find the right weight to the remaining factors to find my optimal fit. – SRKX Jul 14 '12 at 14:41
@SRKX, why don't you simply drop the correlated factors from further analysis? It is easy to do. Moreover, stepwisefit will do this for you. – Paul Jul 14 '12 at 15:54

## 1 Answer

You should use the method "Elastic Net", instead of the Stepwise method.

You can put the highly correlated predictors in your multiple linear regression, however, you won't get accurate results from your stepwise analysis unless you regularize your regression.

The regularized linear regression method is "lasso" in Matlab. When you are using that, you should set the alpha to something between 0 to 1, in order to use the Elastic Net method, instead of the default Lasso method. That is because you have predictors which are correlated, and you would like your regression model to consider this fact.

-
default
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 4, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9582314491271973, "perplexity_flag": "middle"}