Bootstrap wind data to account for autocorrelation and obtain new slope

4 次查看(过去 30 天)
Hi there,
I have a sample dataset (12783x2) containing the time and wind speed values overs 35 years (6 hour intervals). I have noted that there is a large amount of autocorrelation in the wind data and thus I would like to use bootstrapping re-sampling to perform a new regression on the data with time to find a new slope that describes the long term trend in the wind speeds.
I have been trying a few options with bootstrap but cannot get my polyfit function to output a new slope for the resampled dataset. Instead I get multiple slopes and intercepts.
bootstrp(1000,@polyfit,test(:,1),test(:,2),1);
I know I am writing this code incorrectly. Any idea how I can just get one new slope of the bootstrapped data?
I will also like to perform the wblft() function on the data as well to see if the resampled data with bootstrp has a similar distribution to the original.

回答(1 个)

Cloud Blend
Cloud Blend 2017-3-27
Because 1000 is your first argument, bootstrp is iterating on your data 1000 times, and returning 1000 slopes and 1000 intercepts. You could simply take the mean
mean(bootstrp(1000,@polyfit,test(:,1),test(:,2),1),1);
If your resamples are sparse enough, that may help with your autocorrelation problem. You may want to compute autocorrelation for a number of different time lags and decide what is best using a high p value or a rho that is close to zero:
maxSamples = 1000; %prevents very large correlations from taking too much memory
maxSkip = 1461; %1 year
rhos = NaN(1, maxSkip);
ps = NaN(1, maxSkip);
for frameSkip = 1:maxSkip
sampleTotal = size(test,1)-frameSkip;
sampleInterval = floor(sampleTotal / maxSamples);
bufferSize = min(maxSamples, sampleTotal);
buffer = NaN(bufferSize,2);
sourceCounter = 1;
for destCounter = 1:bufferSize
buffer(destCounter,1) = test(sourceCounter, 2);
buffer(destCounter,2) = test(sourceCounter + frameSkip, 2);
sourceCounter = sourceCounter + sampleInterval;
end
[rho, p] = corr(buffer);
rhos(frameSkip) = rho(2);
ps(frameSkip) = p(2);
end

Community Treasure Hunt

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

Start Hunting!

Translated by