upper and lower bounds on loess

8 ビュー (過去 30 日間)
Kristian Smits
Kristian Smits 2021 年 1 月 12 日
回答済み: Shishir Reddy 2025 年 1 月 3 日
I am trying to smooth my x, y data via loess and rloess, however I am unable to create upper and lower bounds. In "computational Statistics handbok with MATLAB" they use the function "csloess" to create the upper/lower boundaries. I have not been able to find this function anywhere, so if anyone has suggestions I would love to hear them!
I can smooth my data easily using loess, but I can't create a fit type, as that requires x,y,z data.

回答 (1 件)

Shishir Reddy
Shishir Reddy 2025 年 1 月 3 日
Hi Kristian
Creating upper and lower bounds for a LOESS (Locally Estimated Scatterplot Smoothing) fit involves estimating the variability of the fit at each point, which can be done using bootstrapping or other resampling methods.
Here's a general approach using MATLAB:
1. Fit LOESS to Your Data: Use MATLAB's fit function with the loess method to fit your data.
x = your_x_data;
y = your_y_data;
span = 0.3;
loessFit = fit(x, y, 'loess', 'Span', span);
2. Bootstrap Resampling: Perform bootstrap resampling to estimate the variability of the LOESS fit. This involves repeatedly sampling your data with replacement and fitting LOESS to each sample.
numBootstraps = 1000;
bootstrapFits = zeros(length(x), numBootstraps);
for i = 1:numBootstraps
indices = randi(length(x), length(x), 1);
xSample = x(indices);
ySample = y(indices);
bootFit = fit(xSample, ySample, 'loess', 'Span', span);
bootstrapFits(:, i) = feval(bootFit, x);
end
3. Calculate Confidence Intervals: Compute the upper and lower bounds for the confidence intervals from the bootstrap results.
alpha = 0.05; % 95% confidence interval
lowerBound = quantile(bootstrapFits, alpha/2, 2);
upperBound = quantile(bootstrapFits, 1 - alpha/2, 2);
The span parameter in LOESS controls the amount of smoothing. So, you may need to adjust it based on the data.
For more information regarding fit, quantile kindly refer the following documentation links -
I hope this helps.

カテゴリ

Help Center および File ExchangeSmoothing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by