make_scaled_dist | R Documentation |
This function computes scaled distances from whichever relevant argument it can use (see Details). The result can directly by used as input for computation of the Matérn correlation matrix. It is usually called internally by HLCor, so that users may ignore it, except if they wish to control the distance used through control.dist$method
, or the parametrization of the scaling through control.dist$rho.mapping
. control.dist$method
provide access to the distances implemented in the proxy
package, as well as to "EarthChord"
and "Earth"
methods defined in spaMM
(see Details).
make_scaled_dist(uniqueGeo, uniqueGeo2=NULL, distMatrix, rho,
rho.mapping=seq_len(length(rho)),
dist.method="Euclidean",
return_matrix=FALSE)
uniqueGeo |
A matrix of geographical coordinates (e.g. 2 columns for latitude and longitude), without replicates of the same location. |
uniqueGeo2 |
NULL, or a second matrix of geographical coordinates, without replicates of the same location.
If NULL, scaled distances among |
distMatrix |
A distance matrix. |
rho |
A scalar or vector of positive values. Scaled distance is computed as |
rho.mapping |
A set of indices controlling which elements of the |
dist.method |
|
return_matrix |
Whether to return a |
The function uses the distMatrix
argument if provided, in which case rho must be a scalar. Vectorial rho
(i.e., different scaling of different dimensions) is feasible only by providing uniqueGeo
.
The dist.method
argument gives access to distances implemented in the proxy
package, or to user-defined ones that are made accessible to proxy
through its database. Of special interest for spatial analyses are distances computed from longitude and latitude (proxy
implements "Geodesic"
and "Chord"
distances but they do not use such coordinates: instead, they use Euclidean distance for 2D computations, i.e. Euclidean distance between points on a circle rather than on a sphere). spaMM implements two such distances: "Earth"
and "EarthChord"
, using longitude and latitude inputs in that order (see Examples). The "EarthChord"
distance is the 3D Euclidean distance “through Earth”. The "Earth"
distance is also known as the orthodromic or great-circle distance, on the Earth surface. Both distances return values in km and are based on approximating the Earth by a sphere of radius 6371.009 km.
A matrix or dist
object. If there are two input matrices, rows of the return value correspond to rows of the first matrix.
data("blackcap")
## a biologically not very meaningful, but syntactically correct example of rho.mapping
fitme(migStatus ~ 1 + Matern(1|longitude+latitude+means),
data=blackcap, fixed=list(nu=0.5,phi=1e-6),
init=list(rho=c(1,1)), control.dist=list(rho.mapping=c(1,1,2)))
## Using orthodromic distances:
# order of variables in Matern(.|longitude+latitude) matters;
# Matern(1|latitude+longitude) should cause a warning
fitme(migStatus ~ 1 + Matern(1|longitude+latitude),data=blackcap,
method="ML", fixed=list(nu=0.5,phi=1e-6),
control.dist=list(dist.method="Earth"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.