As a clarification: if 0 falls within the 95% confidence interval of the slope, then the slope is not significantly different than zero at p=0.05. So I would like to find the % confidence interval at which the edge of the confidence interval equals zero, and then back-calculate the p-value at which the slope is significant.
Curve fitting toolbox linear fit to find confidence interval that includes zero
3 次查看(过去 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
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
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
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)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!