find_rho: Estimate local correlation $rho$ between two variables.

View source: R/find_rho.R

find_rhoR Documentation

Estimate local correlation $\rho$ between two variables.

Description

This function uses the local likelihood function proposed by Hjort & Jones (1996) to find an estimate of the local correlation $\rho$ given $n$ bivariate observations and a vector $b$ with the specified bandwidths. Note that the code use the simplifying assumption that the the marginals are standard normal, which reduces the number of parameters to estimate from five to one. This function is based on code from H\aakon Otneim.

Usage

find_rho(
  data,
  grid,
  b,
  .kernel = c("normal", "uniform"),
  return_arguments = FALSE
)

Arguments

data

A matrix containing the observations, one bivariate observation in each row.

grid

A matrix containing the points where we want to find the local correlations, one bivariate point in each row.

b

A vector containing the two bandwidths to use.

.kernel

Specification of the kernel to use, either normal or uniform, with default being the normal one if none is selected. Note: The uniform-kernel takes much longer to compute (a factor of ten when used on a small sample of size $n=200$).

return_arguments

Logical argument, default FALSE, that can be used to include the three arguments data, grid and b in the result from this function.

Details

In the computation, a product kernel that either is based on the standard normal distribution or the uniform distribution is used. The default kernel is the normal one, since it seems to behave better than the uniform kernel with regard to being able to get a proper result (i.e. not NA) and since it also seems to compute a bit faster when a computation is possible. Note that the code computes the required densities (related to the normal distribution) directly instead of using dnorm and dmvnorm, since that gives a speed gain.

Value

The result of this function is a list. For each grid-point there will be an estimate of the local correlation and the log-density of the corresponding local Gaussian approximation at that point. When return_arguments is TRUE, the three arguments data, grid and b will also be included.

References

Hjort, N. L., and Jones, M. C.: "Locally parametric nonparametric density estimation.", The Annals of Statistics (1996): 1619-1647.


LAJordanger/localgaussSpec documentation built on May 6, 2023, 4:31 a.m.