get_elts_ab: The R implementation to get the elements necessary for...

Description Usage Arguments Details Value Examples

View source: R/genscore.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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) 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) 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/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) or not. Default to TRUE.

profiled_if_noncenter

A boolean, whether in the profiled setting (λ_η=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 Γ matrix and the g vector for generalized score matching.

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

Γ_j=Γ_{KK,j}-Γ_{Kη,j}Γ_{ηη,j}^(-1)Γ_{Kη}'.

Similarly, in the non-profiled non-centered setting, g can be partitioned p parts, each with a p-vector g_{K,j} and a scalar g_{η,j}. In the centered setting, only g_{K,j} is needed. In the profiled non-centered case,

g_j=g_{K,j}-Γ_{Kη,j}Γ_{ηη,j}^(-1)g_{η,j}.

The formulae for the pieces above are

Γ_{KK,j}=1/n*∑_{i=1}^n h(Xij)*Xij^(2a-2)*Xi^a*(Xi^a)',

Γ_{Kη,j}=-1/n*∑_{i=1}^n h(Xij)*Xij^(a+b-2)*Xi^a,

Γ_{ηη,j}=1/n*∑_{i=1}^n h(Xij)*Xij^(2b-2),

g_{K,j}=1/n*∑_{i=1}^n (h'(Xij)*Xij^(a-1)+(a-1)*h(Xij)*Xij^(a-2))*Xi^a+a*h(Xij)*Xij^(2a-2)*e_{j,p},

g_{η,j}=1/n*∑_{i=1}^n -h'(Xij)*Xij^(b-1)-(b-1)*h(Xij)*Xij^(b-2)),

where e_{j,p} is the p-vector with 1 at the j-th position and 0 elsewhere.

In the profiled non-centered setting, the function also returns t1 and t2 defined as

t1=Γ_{ηη}^(-1)g_{η}, t2=Γ_{ηη}^(-1)Γ_{Kη}',

so that \hat{η}=t1-t2*vec(\hat{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 Γ after applying the multiplier.

setting

The setting. Same as input.

g_K

The g vector. In the non-profiled non-centered setting, this is the g sub-vector corresponding to K.

Gamma_K

The Γ matrix with no diagonal multiplier. In the non-profiled non-centered setting, this is the Γ sub-matrix corresponding to K.

g_eta

Returned in the non-profiled non-centered setting. The g sub-vector corresponding to η.

Gamma_K_eta

Returned in the non-profiled non-centered setting. The Γ sub-matrix corresponding to interaction between K and η.

Gamma_eta

Returned in the non-profiled non-centered setting. The Γ sub-matrix corresponding to η.

t1,t2

Returned in the profiled non-centered setting, where the η estimate can be retrieved from t1-t2*\hat{K} after appropriate resizing.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)

genscore documentation built on April 28, 2020, 1:06 a.m.