Curve fitting toolbox linear fit to find confidence interval that includes zero

조회 수: 5 (최근 30일)
Hi, I'm trying to find out the p-value for which the slope of my linear fit is significantly different than zero. I am using the CFTOOL function with a linear polynomial fit. One of the outputs is the 95% confidence interval, but I would like to find at what confidence interval is one of the bounds equal to zero. Do you know of a way to do this?
I have tried other functions but CFTOOL seems to work best because I have multiple y values for each x. I also have NaN's in the data that CFTOOL correctly ignores, whereas the other functions do not handle the NaN's well.
Thanks! Nick
  댓글 수: 3
the cyclist
the cyclist 2013년 8월 30일
I don't have the curve fitting toolbox, so I cannot experiment.
Can you be more specific about what the output looks like, ideally with an example?
Matt J
Matt J 2013년 8월 30일
One of the outputs is the 95% confidence interval, but I would like to find at what confidence interval is one of the bounds equal to zero.
In order to calculate that, you would have to know the true slope, wouldn't you? The more the true slope differs from zero, the larger the % confidence interval needed to include zero.

댓글을 달려면 로그인하십시오.

답변 (1개)

the cyclist
the cyclist 2013년 8월 30일
I think I understand what you mean now. Doesn't CFTOOL directly output that p-value?
If not, I think you can calculate the p-value as follows. I tested this a bit, and got reasonable results, but definitely check this. This assumes that CFTOOL makes normality assumptions.
% Significance of cftool output (default is probably 0.05)
ALPHA = 0.05;
% z-score of the lower bound of a unit normal
z95lower = norminv(ALPHA/2);
% Sample mean slope as calculated by cftool
meanSlope = 3; % <------- Get this value from output of cftool
% Confidence interval as calculated by cftool
lowerCI = 0.5; % <------- Get this value from output of cftool
% Inferred standard error of the mean of the slope
stdErr = (meanSlope - lowerCI)/z95lower;
% z-score of zero (the number of standard errors that zero is away from the mean slope)
z_score_at_zero = meanSlope/stdErr;
% p-value of that z-score
p_value_from_zero = 2*normcdf(z_score_at_zero)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by