Adding command to find p-value to script

조회 수: 2 (최근 30일)
Imre
Imre 2015년 4월 20일
답변: Star Strider 2015년 4월 20일
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