MATLAB: How to calculate the standard error related to the confidence interval output by the NLPARCI function in the Statistics Toolbox 5.0.1(R14SP1)

errornlparcistandardStatistics and Machine Learning Toolbox

I want to calculate the standard error for a t-distribution with a certain number of degrees of freedom from a confidence interval representing a range over which a specified percentage of the observations will land.

Best Answer

This enhancement has been incorporated in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
There is a well-defined relation between the width of the confidence interval in standard errors and the percentage of observations falling within the confidence interval. To calculate the standard error, first you will need to find the confidence interval. Then you can use the TINV function to calculate the number of standard errors spanned by the confidence interval. Finally, divide the confidence interval by the number of standard errors spanned by the confidence interval to find the standard error.
Here is an illustration of how to compute the standard error:
1. Fit a model using the NLINFIT function, and get the parameters.
load hald
y = heat;
x = ingredients(:,4);
[b,r,J] = nlinfit(y,x,@(b,x) b(1)+b(2)*x, 1:2);
2. Estimate the confidence interval using the NLPARCI function:
alpha = 0.05
ci = nlparci(b,r,J,alpha); % 95% confidence intervals
3. Compute the standard error from the confidence interval using the TINV function:
t = tinv(1-alpha/2,length(y)-length(b));
nlinfit_se = (ci(:,2)-ci(:,1)) ./ (2*t) % Standard Error