get_elts_ab {genscore}R Documentation

The R implementation to get the elements necessary for calculations for general a and b.

Description

The R implementation to get the elements necessary for calculations for general aa and bb.

Usage

get_elts_ab(
  hdx,
  hpdx,
  x,
  a,
  b,
  setting,
  centered = TRUE,
  profiled_if_noncenter = TRUE,
  scale = "",
  diagonal_multiplier = 1
)

Arguments

hdx

A matrix, h(x)h(\mathbf{x}) applied to the distance of x from the boundary of the domain, should be of the same dimension as x.

hpdx

A matrix, h(x)h'(\mathbf{x}) applied to the distance of x from the boundary of the domain, should be of the same dimension as x.

x

An n by p matrix, the data matrix, where n is the sample size and p the dimension.

a

A number, must be strictly larger than b/2b/2.

b

A number, must be >= 0.

setting

A string that indicates the distribution type. Returned without being checked or used in the function body.

centered

A boolean, whether in the centered setting (assume μ=η=0\boldsymbol{\mu}=\boldsymbol{\eta}=0) or not. Default to TRUE.

profiled_if_noncenter

A boolean, whether in the profiled setting (λη=0\lambda_{\boldsymbol{\eta}}=0) if non-centered. Parameter ignored if centered=TRUE. Default to TRUE.

scale

A string indicating the scaling method. Returned without being checked or used in the function body. Default to "norm".

diagonal_multiplier

A number >= 1, the diagonal multiplier.

Details

Computes the Γ\boldsymbol{\Gamma} matrix and the g\boldsymbol{g} vector for generalized score matching.

Here, Γ\boldsymbol{\Gamma} is block-diagonal, and in the non-profiled non-centered setting, the jj-th block is composed of ΓKK,j\boldsymbol{\Gamma}_{\mathbf{KK},j}, ΓKη,j\boldsymbol{\Gamma}_{\mathbf{K}\boldsymbol{\eta},j} and its transpose, and finally Γηη,j\boldsymbol{\Gamma}_{\boldsymbol{\eta\eta},j}. In the centered case, only ΓKK,j\boldsymbol{\Gamma}_{\mathbf{KK},j} is computed. In the profiled non-centered case,

ΓjΓKK,jΓKη,jΓηη,j1ΓKη.\boldsymbol{\Gamma}_{j}\equiv\boldsymbol{\Gamma}_{\mathbf{KK},j}-\boldsymbol{\Gamma}_{\mathbf{K}\boldsymbol{\eta},j}\boldsymbol{\Gamma}_{\boldsymbol{\eta}\boldsymbol{\eta},j}^{-1}\boldsymbol{\Gamma}_{\mathbf{K}\boldsymbol{\eta}}^{\top}.

Similarly, in the non-profiled non-centered setting, g\boldsymbol{g} can be partitioned pp parts, each with a pp-vector gK,j\boldsymbol{g}_{\mathbf{K},j} and a scalar gη,jg_{\boldsymbol{\eta},j}. In the centered setting, only gK,j\boldsymbol{g}_{\mathbf{K},j} is needed. In the profiled non-centered case,

gjgK,jΓKη,jΓηη,j1gη,j.\boldsymbol{g}_j\equiv\boldsymbol{g}_{\mathbf{K},j}-\boldsymbol{\Gamma}_{\mathbf{K}\boldsymbol{\eta},j}\boldsymbol{\Gamma}_{\boldsymbol{\eta\eta},j}^{-1}g_{\boldsymbol{\eta},j}.

The formulae for the pieces above are

ΓKK,j1ni=1nh(Xj(i))Xj(i)2a2X(i)aX(i)a,\boldsymbol{\Gamma}_{\mathbf{KK},j}\equiv\frac{1}{n}\sum_{i=1}^nh\left(X_j^{(i)}\right){X_j^{(i)}}^{2a-2}{\boldsymbol{X}^{(i)}}^a{{\boldsymbol{X}^{(i)}}^a}^{\top},

ΓKη,j1ni=1nh(Xj(i))Xj(i)a+b2X(i)a,\boldsymbol{\Gamma}_{\mathbf{K}\boldsymbol{\eta},j}\equiv-\frac{1}{n}\sum_{i=1}^nh\left(X_j^{(i)}\right){X_j^{(i)}}^{a+b-2}{\boldsymbol{X}^{(i)}}^a,

Γηη,j1ni=1nh(Xj(i))Xj(i)2b2,\boldsymbol{\Gamma}_{\boldsymbol{\eta\eta},j}\equiv\frac{1}{n}\sum_{i=1}^nh\left(X_j^{(i)}\right){X_j^{(i)}}^{2b-2},

gK,j1ni=1n(h(Xj(i))Xj(i)a1+(a1)h(Xj(i))Xj(i)a2)X(i)a+ah(Xj(i))Xj(i)2a2ej,p,\boldsymbol{g}_{\mathbf{K},j}\equiv\frac{1}{n}\sum_{i=1}^n\left(h'\left(X_j^{(i)}\right){X_j^{(i)}}^{a-1}+(a-1)h\left(X_j^{(i)}\right){X_j^{(i)}}^{a-2}\right){\boldsymbol{X}^{(i)}}^a+ah\left(X_j^{(i)}\right){X_j^{(i)}}^{2a-2}\boldsymbol{e}_{j,p},

gη,j1ni=1nh(Xj(i))Xj(i)b1(b1)h(Xj(i))Xj(i)b2,\boldsymbol{g}_{\boldsymbol{\eta},j}\equiv\frac{1}{n}\sum_{i=1}^n-h'\left(X_j^{(i)}\right){X_j^{(i)}}^{b-1}-(b-1)h\left(X_j^{(i)}\right){X_j^{(i)}}^{b-2},

where ej,p\boldsymbol{e}_{j,p} is the pp-vector with 1 at the jj-th position and 0 elsewhere.

In the profiled non-centered setting, the function also returns t1t_1 and t2t_2 defined as

t1Γηη1gη,t2Γηη1ΓKη,\boldsymbol{t}_1\equiv\boldsymbol{\Gamma}_{\boldsymbol{\eta\eta}}^{-1}\boldsymbol{g}_{\boldsymbol{\eta}},\quad\boldsymbol{t}_2\equiv\boldsymbol{\Gamma}_{\boldsymbol{\eta\eta}}^{-1}\boldsymbol{\Gamma}_{\mathbf{K}\boldsymbol{\eta}}^{\top},

so that η^=t1t2vec(K^).\hat{\boldsymbol{\eta}}=\boldsymbol{t}_1-\boldsymbol{t}_2\mathrm{vec}(\hat{\mathbf{K}}).

Value

A list that contains the elements necessary for estimation.

n

The sample size.

p

The dimension.

centered

The centered setting or not. Same as input.

scale

The scaling method. Same as input.

diagonal_multiplier

The diagonal multiplier. Same as input.

diagonals_with_multiplier

A vector that contains the diagonal entries of Γ\boldsymbol{\Gamma} after applying the multiplier.

setting

The setting. Same as input.

g_K

The g\boldsymbol{g} vector. In the non-profiled non-centered setting, this is the g\boldsymbol{g} sub-vector corresponding to K\mathbf{K}.

Gamma_K

The Γ\boldsymbol{\Gamma} matrix with no diagonal multiplier. In the non-profiled non-centered setting, this is the Γ\boldsymbol{\Gamma} sub-matrix corresponding to K\mathbf{K}.

g_eta

Returned in the non-profiled non-centered setting. The g\boldsymbol{g} sub-vector corresponding to η\boldsymbol{\eta}.

Gamma_K_eta

Returned in the non-profiled non-centered setting. The Γ\boldsymbol{\Gamma} sub-matrix corresponding to interaction between K\mathbf{K} and η\boldsymbol{\eta}.

Gamma_eta

Returned in the non-profiled non-centered setting. The Γ\boldsymbol{\Gamma} sub-matrix corresponding to η\boldsymbol{\eta}.

t1, t2

Returned in the profiled non-centered setting, where the η\boldsymbol{\eta} estimate can be retrieved from t1t2K^\boldsymbol{t_1}-\boldsymbol{t_2}\hat{\mathbf{K}} after appropriate resizing.

Examples

n <- 50
p <- 30
eta <- rep(0, p)
K <- diag(p)
domain <- make_domain("R+", p=p)
x <- gen(n, setting="ab_1/2_7/10", abs=FALSE, eta=eta, K=K, domain=domain, finite_infinity=100, 
       xinit=NULL, seed=2, burn_in=1000, thinning=100, verbose=FALSE)
h_hp <- get_h_hp("min_pow", 1.5, 3)
h_hp_dx <- h_of_dist(h_hp, x, domain) # h and h' applied to distance from x to boundary
elts <- get_elts_ab(h_hp_dx$hdx, h_hp_dx$hpdx, x, a=0.5, b=0.7, setting="ab_1/2_7/10",
            centered=TRUE, scale="norm", diag=1.5)
elts <- get_elts_ab(h_hp_dx$hdx, h_hp_dx$hpdx, x, a=0.5, b=0.7, setting="ab_1/2_7/10",
            centered=FALSE, profiled_if_noncenter=TRUE, scale="norm", diag=1.7)
elts <- get_elts_ab(h_hp_dx$hdx, h_hp_dx$hpdx, x, a=0.5, b=0.7, setting="ab_1/2_7/10",
            centered=FALSE, profiled_if_noncenter=FALSE, scale="norm", diag=1.9)

[Package genscore version 1.0.2.2 Index]