필터 지우기
필터 지우기

correlazione tra più variabili indipendenti con una dipendente

조회 수: 6 (최근 30일)
Alexandra Corlade
Alexandra Corlade 2024년 3월 1일
답변: Chetan 2024년 3월 5일
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!