correlazione tra più variabili indipendenti con una dipendente

4 次查看(过去 30 天)
Salve a tutti,
Sto cercando di correlare 11 variabili indipendenti contenenti anche campi NaN con una variabile dipendente. Ho utilizzato la funzione corr raggruppando le 11 variabili in un unica matrice T, per una parte delle variabili mi dà NaN come risultato. Come faccio a fare la correlazione non considerando i campi NaN ed avere quindi i risultati desiderati?
Grazie mille per eventuali risposte!
A.C.

回答(1 个)

Chetan
Chetan 2024-3-5
I understand that you're working on correlating 11 independent variables with one dependent variable in MATLAB, facing issues with NaN values affecting your correlation results.
To tackle NaN values during your analysis, MATLAB's `corr` function with the 'Rows','pairwise' option is your go-to solution. It computes correlations while ignoring NaN values, considering only non-NaN pairs of rows for each variable pair.
Here is a sample code for the same
% Assuming T is your matrix with variables as columns
correlationResults = corr(T, 'Rows', 'pairwise');
Additionally you should:
  • Verify that `T` is structured correctly, with each variable as a column.
  • Consider using MATLAB's visualization tools to interpret the correlation matrix more effectively
Refer to the following MathWorks Documentation:
Thanks
Chetan

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!