neuster Stand
This commit is contained in:
+11
-2
@@ -40,6 +40,9 @@ source(here::here("R", "graphon_distribution.R"))
|
||||
#' @param Fv Cumulative distribution function of the latent variable
|
||||
#' \eqn{v}. Also has to be vectorised. Typical examples are
|
||||
#' `pnorm`, `pexp`, ….
|
||||
#' @param fX Optional function(z) returning the *known* pdf of the *scalar*
|
||||
#' covariate when `ncol(X_matrix)==1 && length(a)==1`. If supplied,
|
||||
#' the analytic CDF `pgraphon_analytical_1d` is used.
|
||||
#' @param sample_X_fn
|
||||
#' Function with a single argument `n`. It must return an
|
||||
#' \eqn{n \times p} matrix (or an object coercible to a matrix) of
|
||||
@@ -111,6 +114,7 @@ compute_matrix <- function(
|
||||
K,
|
||||
fv,
|
||||
Fv,
|
||||
fX=NULL,
|
||||
sample_X_fn=NULL,
|
||||
matrix_X = NULL,
|
||||
guard = sqrt(.Machine$double.eps),
|
||||
@@ -127,6 +131,7 @@ compute_matrix <- function(
|
||||
if (!is.null(matrix_X) && !is.matrix(matrix_X)) stop("matrix_X must be either null or a matrix")
|
||||
if (is.null(matrix_X) && is.null(sample_X_fn)) stop("Either 'matrix_X' or 'sample_X_fn' must be supplied!")
|
||||
if (!is.null(matrix_X) && !is.null(sample_X_fn)) warning("Both arguments 'matrix_X' and `sample_X_fn` is given. Priority is given by to the first!")
|
||||
if (!is.null(fX) && !is.function(fX)) stop("'fX' must be a density function")
|
||||
|
||||
## 1.2 Generate the Matrix X of covariates ===================================
|
||||
# If the argument matrix_X is present, use this matrix, otherwise generate one
|
||||
@@ -146,14 +151,18 @@ compute_matrix <- function(
|
||||
}
|
||||
|
||||
## 1.3 Create conditional density ============================================
|
||||
empir_cond_density <- create_cond_density(a, fv, Fv, X)
|
||||
# this is not used in the computation
|
||||
# empir_cond_density <- create_cond_density(a, fv, Fv, X)
|
||||
|
||||
## 1.4 Compute the graphon quantiles =========================================
|
||||
k <- seq(0, K) / K
|
||||
if (!is.null(guard)) {
|
||||
k[1] <- guard
|
||||
}
|
||||
graphon_quantiles <- qgraphon(k, a = a, Fv = Fv, X_matrix = X)
|
||||
# here there is an automatic switch included, if fX is not null and we have a
|
||||
# scalar case, then qpgrahon automatically switches to the analytical
|
||||
# expression. The intended use is for small values of n
|
||||
graphon_quantiles <- qgraphon(k, a = a, Fv = Fv, X_matrix = X, fX= fX)
|
||||
|
||||
## 1.5 Build the matrix Q ====================================================
|
||||
inner_products = as.vector(X %*% a)
|
||||
|
||||
Reference in New Issue
Block a user