View source: R/functions_range.R
compute_effective_range | R Documentation |
Calculates the effective range for a spline basis matrix.
compute_effective_range(
X,
coords = X[, c("x", "y")],
df = 3,
nsamp = min(1000, nrow(X)),
smoothedCurve = FALSE,
newd = seq(0, 1, 100),
scale_factor = 1,
returnFull = FALSE,
cl = NULL,
namestem = "",
inds = NULL,
verbose = TRUE,
span = 0.1
)
compute_effective_range_nochecks(
X,
inds,
newd,
D,
smoothedCurve = FALSE,
scale_factor = 1,
returnFull = FALSE,
cl = NULL,
span = 0.1
)
X |
Matrix of spline values. See |
coords |
Matrix of point coordinates. Defaults to the |
df |
Degrees of freedom for which effective range should be computed. |
nsamp |
Number of observations from |
smoothedCurve |
Should a smoothed curve be fit to the relationship between the distances and the smoothed weights (TRUE), or just find the smallest distance that has a negative weight (FALSE) |
newd |
Distance values at which to make loess predictions. Should correspond to distances in the same units as |
scale_factor |
Factor by which range should be scaled. Often physical distance corresponding to resolution of grid. |
returnFull |
Should the mean and median curves be returned (TRUE), or just the range value of where they first cross zero (FALSE). |
cl |
Cluster object, or number of cluster instances to create. Defaults to no parallelization. |
namestem |
Stem of names of columns of X corresponding to evaluated splines.
Defaults to |
inds |
Indices of observations to use for computation. Passed to |
verbose |
Control message printing. |
span |
Passed to |
D |
Distance matrix. |
Using the given TPRS basis and the inputted coordinates, the effective bandwidth is computed for the given degrees of freedom. This is accomplished by computing a distance matrix from the coordinates and a smoothing matrix from the basis.
For each column of smoothing weights, the smallest distance that corresponds with the first negative smoothing weight is obtained and the median of the obtained distances is reported as the effective bandwidth.
The names of columns of X
are assumed to be numeric, with an optional name stem (e.g. "s1", "s2", etc.).
compute_lowCurve
xloc <- runif(n=100, min=0, max=10)
X <- splines::ns(x=xloc, df=4, intercept=TRUE)
colnames(X) <- paste0("s", 1:ncol(X))
xplot <- 0:10
compute_effective_range(X=X, coords=as.matrix(xloc), df=2:4, newd=xplot, namestem="s")
M <- 16
tprs_df <- 10
si <- seq(0, 1, length=M+1)[-(M+1)]
gridcoords <- expand.grid(x=si, y=si)
tprsX <- computeTPRS(coords = gridcoords, maxdf = tprs_df+1)
compute_effective_range(X=tprsX$tprsX, coords=gridcoords, df=3:10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.