Could anyone tell me how to calculate confidence intervals (bounds) of cumulative normal distribution usign matlab. The matlab code is shown below:
x=0:0.01:0.5;
y = cdf('Normal',x,0.2,0.025);
figure(2);plot(x,y);
Let's start from 95% one-sided confidence intervals.
Thank you very much!
Dawei
Frank
Hi Frank,
Thank you very much for your reply which is really helpful. Also I have some more questions, hope you could give me some advices:
1. I have done some codes and could you help me to check whether the code is following what you said.
x=0:0.01:0.5;
mu=0.12;
sigma=0.025;
alpha=0.05;
[a,pcov] = normlike([mu,sigma], x);
[y,yl,yu] = normcdf(x,mu,sigma,pcov,alpha);
figure(2);plot(x,y,'b',x,yl,'r',x,yu,'r');hold on;
2. Could you tell me the value of alpha is for one-sided or two-sided?
3. Do you know how to calculate confidence intervals for other function other than normal cumulative function, e.g. y = exp(z) / (1+exp(z)), where z=a+b*x. This function can be considered as an inverse log-odss function.
Thank you and look forward to your reply.
David
Yes....that looks to be correct.
> 2. Could you tell me the value of alpha is for one-sided or two-sided?
>
alpha is two-sided, meaning if you use alpha = 0.05, this will give
the 95% two-sided confidence intervals
> 3. Do you know how to calculate confidence intervals for other function other than normal cumulative function, e.g. y = exp(z) / (1+exp(z)), where z=a+b*x. This function can be considered as an inverse log-odss function.
>
It should be just a simple transformation. Meaning, if you know the
confidence intervals on x, then the confidence intervals on z should
be a+b*yu and a+b*yl. Of course, I haven't checked this.
Frank
>
> > 3. Do you know how to calculate confidence intervals for other function other than normal cumulative function, e.g. y = exp(z) / (1+exp(z)), where z=a+b*x. This function can be considered as an inverse log-odss function.
> >
>
> It should be just a simple transformation. Meaning, if you know the
> confidence intervals on x, then the confidence intervals on z should
> be a+b*yu and a+b*yl. Of course, I haven't checked this.
>
> Frank
Hi Frank,
Thank you very much for your help! BTW sorry for late reply.
With regards to my third question, I realized the funciton is called Logistic function which is defined as : y = exp(z) / (1+exp(z)).
What I want is to calculate confidence intervals for y. Also z = a+b*x
For the convenience I provide the code:
a=-5;
b=38;
x=0.01:0.01:0.5;
z=a+b.*x;
y = exp(z)./(1+exp(z));
figure(2);plot(x,y);hold on;
My question is Could you tell me how to calculate confidence intervals for y in the plot of x&y.
Could someone help me?
David, I have not been able to follow what you are trying to do.
In your original note you seem to have specified a grid of x values and a
fixed value for mu and sigma, then asked for confidence intervals. Usually
confidence intervals are around an estimate of something. What is being
estimated here?
You are correct that you can get a parameter covariance matrix from normlike
and pass it into normcdf. But for that to be sensible, the parameters you
input to normlike would have to be estimated from the data that you also
pass in. You don't want to pass in just a grid of data values and some
constant parameter values.
-- Tom
Hi Tom,
Thanks for your reply.
1. I think I understand what you mean. Actually sigma and mu are estimated from raw data and x is not even distributed. In my code x = 0:0.01:0.5, but in the raw data, x is between 0 and 0.5 and not even distributed.
Please tell me I understand your comment.
2. Could you tell me how to calcualte confidence intervals for Logistic function ? So plot confidence intervals in the xy plot.
a=-5; b=38;
x=0.01:0.01:0.5;
z=a+b.*x;
y = exp(z)./(1+exp(z));
figure(2);plot(x,y);hold on;
Thank you.
Dawei
Dawei, I don't think anyone can tell you how to calculate confidence
intervals for a=-5 and b=38. All we can tell is how to compute confidence
intervals for parameters that are estimated from data.
Sometimes I like to suggest and answer questions different from the ones
posed. Here are two:
1. How can I calculate intervals such that 95% of the probability
distribution falls in the interval?
"Tom Lane" <tl...@mathworks.nospam.com> wrote in message
news:is8gdd$cs1$1...@newscl01ah.mathworks.com...
>> mu = 5; sigma = 2;
>> norminv([.025 .975],mu,sigma)
ans =
1.0801 8.9199
2. How can I compute confidence intervals for the cdf given the data x from
which I estimated the parameters?
>> x = normrnd(10,2,100,1);
>> [m,s] = normfit(x);
>> [~,pcov] = normlike([m s],x);
>> [p,plo,pup] = normcdf(11.1,m,s,pcov)
p =
0.6433
plo =
0.5654
pup =
0.7156
The Statistics Toolbox doesn't have this set of functions for the logistic
distribution, so you can't use the same approach for that distribution.
-- Tom
hth,
Frank