Adding command to find p-value to script

2 次查看(过去 30 天)
Hello. I need help with a piece of script that I have. I didn't make it myself. I am unable to contact the person who made it at the moment. I wonder if anyone could help me out in here. I understand that those lines calculate the regression values. I was wondering if I could add a line that would also calculate the p-value for my dataset? I understand that the command for finding the p-value is something like [R,P]=CORRCOEF(...) but I wouldn't know how to add that to the script.
for i = 1:nseq
i;
fit_data = NEW((i-1)* diff +1:(i)*diff,:);
CH4_slope = polyfit(fit_vector(1:end,1),fit_data(1:end,7),Regression_model); % regression stats is rendered as "a b c" parameter.
yfit_CH4 = polyval (CH4_slope,fit_vector(1:end,1));
yresid_CH4 = (fit_data(1:end,7)) - yfit_CH4;
SSresid_CH4 = sum(yresid_CH4.^2);
SStotal_CH4 = (length(fit_data(1:end,7))-1)* var(fit_data(1:end,7));
rsg_CH4 = 1 - SSresid_CH4/SStotal_CH4;
% rsg_CH4_adj = rsg_CH4 * (length(fit_data(1:end,10))-1)/(length(fit_data(1:end,10))-length(CH4_slope)-1);

回答(1 个)

Star Strider
Star Strider 2015-4-20
Guessing here, but it looks as though it is calculating the adjusted R² value. I refer you to the Wikipedia article on Coefficient of determination for an explanation.
The p-value is a different discussion. See the ‘See also’ section at the end of that Wikipedia article for links to relevant articles.

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by