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

Description Usage Arguments Details Value References

View source: R/find_rho.R


This function use the local likelihood function proposed by Hjort & Jones (1996) to find an estimate of the local correlation $ρ$ 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.


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



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


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


A vector containing the two bandwidhts to use.


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$).


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


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.


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.


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

LAJordanger/localgaussSpec documentation built on July 28, 2017, 12:15 a.m.