FORCES
FORtran lib for Comp. Env. Sys.
|
Approximates the bandwith h of the kernel for regression. More...
Public Member Functions | |
real(dp) function, dimension(size(ix, 2)) | kernel_regression_h_2d_dp (ix, iy, silverman, mask) |
real(sp) function, dimension(size(ix, 2)) | kernel_regression_h_2d_sp (ix, iy, silverman, mask) |
real(dp) function | kernel_regression_h_1d_dp (ix, iy, silverman, mask) |
real(sp) function | kernel_regression_h_1d_sp (ix, iy, silverman, mask) |
Approximates the bandwith h of the kernel for regression.
Approximates the bandwith h of the kernel for a given dataset x either using Silverman''s rule-of-thumb or a cross-validation method.
By default the bandwidth h is approximated by Silverman''s rule-of-thumb
\[ h = \frac{4}{d+2}^{1/(d+4)} n^{-1/(d+4)} \sigma_{x_i} \]
where \( n \) is the number of given data points, \( d \) is the number of dimensions, and \( \sigma_{x_i} \) is the standard deviation of the data of dimension \( i \).
If the optional argument silverman is set to false, the cross-validation method described by Scott et al. (2005) is applied. Therefore, the likelihood of a given h is maximized using the Nelder-Mead algorithm nelminrange. For large data sets this might be time consuming and should be performed aforehand using the function kernel_density_h.
The dataset x can be single or double precision. The result will have the same numerical precision.
The result of this function can be used as the optional input for kernel_regression.
The code is adapted from the kernel_regression.py of the UFZ CHS Python library.
Example
-> see also example in test directory
Literature
[in] | real(sp/dp) :: x(:)/x(:,:) | 1D or ND array with independent variables |
[in] | real(sp/dp) :: y(:) | 1D array of dependent variables y(i) = f(x(i:)) with unknown f |
[in] | logical, optional :: silverman | By default Silverman''s Rule-of-thumb will be used to approximate the bandwith of the kernel (silverman=true). If silverman=false the Cross-Validation approach is used to estimate the bandwidth. |
[in] | logical, optional :: mask(:) | mask x values at calculation. |
Definition at line 401 of file mo_kernel.f90.
real(dp) function mo_kernel::kernel_regression_h::kernel_regression_h_1d_dp | ( | real(dp), dimension(:), intent(in) | ix, |
real(dp), dimension(:), intent(in) | iy, | ||
logical, intent(in), optional | silverman, | ||
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 1570 of file mo_kernel.f90.
real(sp) function mo_kernel::kernel_regression_h::kernel_regression_h_1d_sp | ( | real(sp), dimension(:), intent(in) | ix, |
real(sp), dimension(:), intent(in) | iy, | ||
logical, intent(in), optional | silverman, | ||
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 1627 of file mo_kernel.f90.
real(dp) function, dimension(size(ix,2)) mo_kernel::kernel_regression_h::kernel_regression_h_2d_dp | ( | real(dp), dimension(:,:), intent(in) | ix, |
real(dp), dimension(:), intent(in) | iy, | ||
logical, intent(in), optional | silverman, | ||
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 1684 of file mo_kernel.f90.
real(sp) function, dimension(size(ix,2)) mo_kernel::kernel_regression_h::kernel_regression_h_2d_sp | ( | real(sp), dimension(:,:), intent(in) | ix, |
real(sp), dimension(:), intent(in) | iy, | ||
logical, intent(in), optional | silverman, | ||
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 1742 of file mo_kernel.f90.