Parametric bootstraping in curve fitting

조회 수: 13 (최근 30일)
Samiul Hayder Choudhury
Samiul Hayder Choudhury 2012년 5월 7일
댓글: Diandian QIU 2013년 9월 30일
I like to use parametric bootstrapping technique to analyze the validity of a data set. The data set is the power received from an RFID tag. My aim is to develop a pathloss model. For this I have to fit the curve. But I want to use bootstrap technique to verify whether or not the collected data are okay. Is there any way to do this?

채택된 답변

Richard Willey
Richard Willey 2012년 5월 7일
In general when I hear the expression parametric bootstrap I think "parametric residual bootstrap"
I'm attaching some simple code that contrasts and parametric and a non parametric residual bootstrap.
%%Bootstrap Examples
% Generate some data
x = 1:10000;
X = x';
Y = 3*X + 5 + randn(10000,1);
% Run a regression
b = regress(Y, [ones(size(X)), X])
%%Parametric residual bootstrap
% Appropriate if you have reason to believe that your residuals are
% normally distributed
YHat = [ones(size(X)), X] * b;
resid = Y - YHat;
foo = fitdist(resid, 'normal');
se = std(bootstrp(1000,@(bootr)regress(YHat+random(foo, size(bootr)),[ones(size(X)), X]),resid))
%%Nonparametric residual bootstrap
% Appropriate if you have reason to believe that your residuals are
% homoskedastic
YHat = [ones(size(X)), X] * b;
resid = Y - YHat;
se = std(bootstrp(1000,@(bootr)regress(YHat+bootr,[ones(size(X)), X]),resid))
  댓글 수: 1
Samiul Hayder Choudhury
Samiul Hayder Choudhury 2012년 5월 14일
Thank you very much for your solution. But I need some information:
1. I did not understand the following line of code:
se = std(bootstrp(1000,@(bootr)regress(YHat+random(foo, size(bootr)),[ones(size(X)), X]),resid))
If you please explain it then it would be helpful for me.
2. If I want to fit a polynomial and then compute the residual, would it be possible?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Tom Lane
Tom Lane 2012년 5월 15일
This line creates a matrix with 1 in one column and X in the other. You could also include X^2 or higher to use polynomials:
[ones(size(X)), X])
This line creates a function that performs a regression on the matrix above, with the response equal to fitted values plus random values from a normal distribution fitted to the original residuals. Richard suggests this is the way to do a parametric bootstrap for regression:
@(bootr)regress(YHat+random(foo, size(bootr)),...)
This line computes the standard error se as the standard deviation of 1000 bootstrap samples generated by applying the above function to the residuals (note that the function is just using the size of the residual vector, not resampling from it):
se = std(bootstrp(1000,...,resid))

Diandian QIU
Diandian QIU 2013년 9월 6일
I got a question, I want to bootstrap the input time series "anomaly_ts" which is the argument for the function "mainf". mainf function should return four variables: [a,b,c,d]=mainf(anomaly_ts)
I did it this way:
[bootstat,bootsam] = bootstrp(1000,@(bootr)mainf(bootr),anomaly_ts);
but why bootstat only contains the bootstrapping result of one variable?
  댓글 수: 1
Diandian QIU
Diandian QIU 2013년 9월 30일
Hi all, I found a post addressing similar question, so I put it here in case anyone else is interested: https://www.mathworks.co.kr/matlabcentral/newsreader/view_thread/329082.
Thanks

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by