Borrar filtros
Borrar filtros

R-squared analysis of scatter plot resulting in NaN

26 visualizaciones (últimos 30 días)
Aine
Aine el 7 de Ag. de 2022
Editada: dpb el 7 de Ag. de 2022
Hi there,
I have two variables (eP and T) each of which are 1x 1244 in size. I have created a scatter plot of eP against T and I have fit a line. However, both variables have some NaN values. When I do an r-squared test I get an R squared value of NaN. Does anyone know how to perform an r-squared test and ignore NaN values?

Respuestas (1)

dpb
dpb el 7 de Ag. de 2022
Editada: dpb el 7 de Ag. de 2022
'Pends on how you did it -- show your code for exact answer to that direction, but --
If you have the Statistics TB, then use
mdl=fitlm(x,y,'linear'); % will ignore NaN automagically
rsqO=mdl.Rsquared.Ordinary; % ordinary r-squared
rsqA=mdl.Rsquared.Adjusted; % adjusted r-squared
will handle it transparently.
Otherwise,
isOK=all(isfinite([ep T]),2); % indices of those with NaN in neither variable
use ep(isOK), T(isOK) in your other code.

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by