comp.soft-sys.matlab - The MathWorks calculation and visualization package.
Hi, "bootci" from statistics toolbox can find the confidence interval for a parameter. I have an older version of statistics toolbox, which do not have this command. Is there any other way to find the confidence interval. Thanks in advance, Raj
I need to add a 95% confidence ellipse to an XY scatter plot. Schwarz's CONFELLIPSE2 code below, submitted to this group in 1998, will do this, However, I'd like to produce a Bootstrapped confidence ellipse. I can use BOOTSTRP in the Statistics Toolbox to resample with replacement and obtain a bootstrap statistic...I'm just unsure WHAT to bootstrap. Any suggestions? Dave -----BEGIN MATLAB CODE:----- function [hh,exy] = confellipse2(xy,conf) %CONFELLIPSE2 Draws a confidence ellipse. % CONFELLIPSE2(XY,CONF) draws a confidence ellipse on the current axes % which is calculated from the n-by-2 matrix XY and encloses the % fraction CONF (e.g., 0.95 for a 95% confidence ellipse). % H = CONFELLIPSE2(...) returns a handle to the line. % written by Douglas M. Schwarz % XXXX@XXXXX.COM % last modified: 12 June 1998 n = size(xy,1); mxy = mean(xy); numPts = 181; % The number of points in the ellipse. th = linspace(0,2*pi,numPts)'; p = 2; % Dimensionality of the data, 2-D in this case. k = finv(conf,p,n-p)*p*(n-1)/(n-p); [pc,score,lat] = princomp(xy); ab = diag(sqrt(k*lat)); exy = [cos(th),sin(th)]*ab*pc' + repmat(mxy,numPts,1); % Add ellipse to current plot h = line(exy(:,1),exy(:,2),'Clipping','off'); if nargout > 0 hh = h; end -----END MATLAB CODE:-----
Hi there, Suppose I have the simple linear model y=b0+b1*x1+b2*x2+e. I want to estimate b0,b1,b2 and calculate a confidence interval for them. Then I want to see how many times the CI contains the true parameter. If I was making everything right, for 1000 repetitions, that should be approximately 950 times. But I am getting 1000 times as a result. What wrong with my code? And another question. The formula used for estimating 95% CI in the regress function is b0_hat-Za*SE(b0_hat) where Za=1.96 right? But nor this formula, nor the more precise Za=1.95996398454002 seems to agree exactly (4 decimals) with the result given by bint in the regress function. Precision is not much of a problem, all I want to know is the correct formula. And what about confidence intervals when I have weighted regression (lscov). The formula there uses a t distribution? n=200; b0=20; b1=3; b2=4; lam=3; for rep=1:1000 e=normrnd(0,10,1,n); x1=exprnd(lam,1,n)'; x2=exprnd(5,1,n)'; X = [ones(size(x1)) x1 x2]; y=b0+b1.*x1+b2.*x2+e'; [b_ols bint]=regress(y,X); cover1(rep)=(bint(1)<b0<bint(4)); cover2(rep)=(bint(2)<b1<bint(5)); cover3(rep)=(bint(3)<b2<bint(6)); end cover1=sum(cover1) cover2=sum(cover2) cover3=sum(cover3)
Hi, I would like to know if it is possible to put subscript indices to compute confidence intervals, for exemple something like this (which doesn't work): for k=1:10 [MUHAT(k) SIGMAHAT(k) MUCI(k) SIGMACI(k)]=normfit(x); end where "x" is a vector of data that changes 10 times according to another loop (which I mention mention here for simplicity). Thanks a lot for your help.