From: Nathan Jensen on 29 Jul 2010 15:18 My question: I would like to know if there is a way to use the function polyfit in a bootstrap analysis. My data: X = 36.06 45.12 31.43 34.31 14.75 24.40 24.75 24.75 24.65 24.63 Y = 150.91 199.90 145.15 147.21 91.241 127.44 128.01 125.02 131.6 124.93 My first attempt: [poly,err]=bootstrp(1,'polyfit',X,Y,1); Output: poly = 2.69174220779397 57.2426836167028 err = 5 1 3 4 8 8 3 1 10 6 Unfortunately, this is very different from simply using: [poly,err]=polyfit(X,Y,1); where the "err" output is given as: R: [2x2 double] df: 8 normr: 18.5810556361341 Thus I cannot use polyval correctly for further analysis. Is there a way around this? What am I doing wrong? Thank you, Nate
From: Peter Perkins on 30 Jul 2010 08:33 On 7/29/2010 3:18 PM, Nathan Jensen wrote: > My question: > I would like to know if there is a way to use the function polyfit in a > bootstrap analysis. > > My data: > X = 36.06 45.12 31.43 34.31 14.75 24.40 24.75 24.75 24.65 24.63 > Y = 150.91 199.90 145.15 147.21 91.241 127.44 128.01 125.02 131.6 124.93 > > My first attempt: > [poly,err]=bootstrp(1,'polyfit',X,Y,1); Nathan, I can't tell what you're trying to do. The names that you've given to those outputs from BOOTSTRP lead me to think you expect that BOOTSTRP will return the same things as POLYFIT. It won't. Also, it makes no sense to bootstrap a single iteration, which is what that first 1 does. There's an example in the help showing how to bootstrap a linear regression using REGRESS, you probably want to start there. It does not look much like what you've done, because the usual way to bootstrap a regression is to resample from the residuals. If that's not what you want to do, there are a few other examples that might be a help in getting started. Hope this helps.
From: Richard Willey on 30 Jul 2010 09:40 Hi Nate What specific problem are you trying to solve and why is resampling an appropriate solution? As Peter mentioned, there are a lot of different ways that you apply a bootstrap to a regression. 1. Parametric residual bootstraps 2. Nonparameteric residual bootstraps 3. Paired bootstraps 4. Wild bootstraps Different techniques make different assumptions about the characteristics of the data. For example, a parametric residual bootstrap will typically give the most accuracte results, however, you shouldn't apply this technique if you have reason to believe that your residuals don't follow a normal distribution. The technique that you're using - a paired bootstrap - is often used if you have heteroskedastic data. However, even in this case, a so-called "Wild Bootstrap" is often preferred. I found the following reference quite valuable in understanding the distinction between the different types of bootstraps and when/how they are applied. http://www.economics.uci.edu/~dbrownst/bootmi.pdf I have some demo code on MATLAB Central that includes an applied example of a paired bootstrap. You might find this useful. http://www.mathworks.com/matlabcentral/fileexchange/27503-matlab-code-for-the-nonparametric-fitting-video
From: Nathan Jensen on 30 Jul 2010 10:20 Peter, I rethought my question, and posted it in a new thread before I saw your post, so sorry for the double post, my bad, but here it is again: My question concerns the output of the bootstrp function. The bootstrap function is as follows: BOOTSTAT = BOOTSTRP(NBOOT,BOOTFUN,D1,...) - or - [BOOTSTAT,BOOTSAM] = BOOTSTRP(...) If BOOTFUN has more than one output (i.e. [P,S] = POLYFIT(X,Y,N)) how to do I get BOOTSTAT to display all of the outputs (i.e. BOOTSTAT = [P,S])? I understand that what I did before was ask MATLAB for the output of [BOOTSTAT,BOOTSAM] = BOOTSTRP(...) and not [P,S] = POLYFIT(X,Y,N), so to be completely redundant, I need MATLAB to give me the output BOOTSTAT = [P,S]. The only reason I was using 1 iteration was for simplicity, in reality I will want to do maybe 1000+ iterations. Thank you though, I will look into the REGRESS function. Richard, I have not had time yet to look through and understand everything that you have written, but I will do so momentarily. I appreciate the help. Again thank you Peter and Richard, Nate
|
Pages: 1 Prev: Axis Image and positioning Next: Interpolation over triangulation |