
Closed-form marginal variance of the directional OU model
Source:R/covariance_directional_ou.R
directional_ou_variance.Rdr(x,x) at each evaluation point – the diagonal of
directional_ou_covariance(), computed directly via the marginal
variance recursion along each edge, without any last-common-ancestor or
transfer-factor work.
Usage
directional_ou_variance(
graph,
kappa,
tau,
PtE = NULL,
sigma_source = NULL,
normalized = TRUE,
cpp = TRUE
)Arguments
- graph
A
metric_graphobject with directional edge weights set (set_edge_weights(directional_weights = ...)) and the vertex weight functions set (setDirectionalWeightFunction()).- kappa
Rate parameter of the OU process (
kappa > 0).- tau
White-noise scale. The stationary marginal variance is
1/(2*kappa*tau^2)– the same convention asMetricGraph:::r_1(). Note this is NOTreciprocal_tau(used elsewhere in the package astau = 1/reciprocal_tau); passtaudirectly here.- PtE
Evaluation points, a matrix with columns
(edge_number, distance_on_edge). Defaults tograph$get_PtE()(the observation locations).- sigma_source
Anchoring variance at the source vertices (indegree 0).
NULL(default) anchors every source at the stationary variance1/(2*kappa*tau^2), matchingQalpha1_edges_custom(..., stationary_points = "all"). Otherwise a numeric vector givingVar(u)at each source vertex, either named by vertex index (as character) or positional in the orderwhich(graph$get_degrees("indegree") == 0).- normalized
If
TRUE(default),distance_on_edgeinPtE/PtE2is in[0, 1]; ifFALSE, distances are absolute.- cpp
If
TRUE(default), use the C++ numeric setup and the shared C++ covariance fill for oriented in-trees and out-trees. Irregular trees use the generic R fallback. Set toFALSEto use the pure-R implementation throughout.
See also
directional_ou_covariance() for the full closed-form
covariance (including the \deqn{r(s,t) = r(a,a) A(a,s) A(a,t)} formula
and the tree/acyclicity requirements).
Examples
edge1 <- rbind(c(0, 0), c(1, 0))
edge2 <- rbind(c(1, 0), c(2, 0))
edge3 <- rbind(c(1, 0), c(1, 1))
graph <- metric_graph$new(edges = list(edge1, edge2, edge3))
#> Starting graph creation...
#> LongLat is set to FALSE
#> Creating edges...
#> Setting edge weights...
#> Computing bounding box...
#> Setting up edges
#> Merging close vertices
#> Total construction time: 0.24 secs
#> Creating and updating vertices...
#> Storing the initial graph...
#> Computing the relative positions of the edges...
graph$set_edge_weights(weights = data.frame(w = c(1, 1, 1)),
directional_weights = "w")
graph$setDirectionalWeightFunction(f_in = function(x) sqrt(x / sum(x)))
directional_ou_variance(graph, kappa = 1, tau = 1,
PtE = rbind(c(1, 0.5), c(2, 0.5)))
#> [1] 0.5 0.5