How to get P value for coefficient of determination in the form of single answer (not in the matrix form)

4 visualizzazioni (ultimi 30 giorni)
I wanted to calculate p value for R2 which i have obtained byusing this code.
yfit = polyval(p,W);
yresid = Wsim(:) - yfit;
SSresid = sum(yresid.^2);
SStotal = (length(Wsim(:))-1) * var(Wsim(:));
R(nok) = 1 - SSresid/SStotal;
I need code after this to calculate p value and i need in the form of single answer (not in the matrix)
I would be extremely gareful if somebody can help.

Risposte (1)

Vatsal il 17 Ott 2023
I understand that you would like to calculate the p-value for 'R2' based on the provided code. To calculate the p-value for ‘R2’ in MATLAB, you can use utilize the following code:
df_regression = 1; % Linear model.
df_residual = length(Wsim(:)) - 2; % N - 2 degrees of freedom for residuals
F_statistic = (R(nok) / df_regression) / ((1 - R(nok)) / df_residual);
p_value = 1 - fcdf(F_statistic, df_regression, df_residual);
To learn more about “fcdf” usage and syntax, you may refer to the MathWorks documentation link below:
I hope this helps!


Scopri di più su Special Functions in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by