How can I set the bandwidth for multivariate kernel regression using ksrmv?
Afficher commentaires plus anciens
I have values in y coming from a function depending on x1 and x2. I applied ksrmv to get fitted values. I want the bandwidth to be h = 0.1. However, when I tried mhat_nw = ksrmv(x1(:),x2(:),0.1, y(:)); I got fitted values that cannot be correct.
When I tried mhat_nw = ksrmv([x1(:), x2(:)],0.1,y(:)); I got the following error:
Error using ksrmv (line 58) x and y have different rows.
Thank you, Marius
The code without bandwidth:
N = 900;
grid = linspace(0,1,30);
[x2 x1] = meshgrid(grid, grid);
x12 = [x1(:) x2(:)];
true = @(x1,x2) (sin(2*pi*x1)+x2);
y = true(x1,x2)+vec2mat(normrnd(0,1,N,1),30);
% The Nadaraya-Watson smoother
mhat_nw = ksrmv([x1(:), x2(:)],y(:));
mhat_nw_fit = y;
mhat_nw_fit(:)= mhat_nw.f;
Réponses (0)
Catégories
En savoir plus sur Regression dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!