full_design1: Design matrix for pms parametrization given the max degree of...

Description Usage Arguments Details Value Examples

View source: R/design_mat.R

Description

Design matrix for pms parametrization given the max degree of the Hurdle polynomial.

Usage

1
full_design1(Vo, Yo, right, V_degree = 1, Y_degree = 1, Y_V_degree = 1)

Arguments

Vo

A numerical matrix of the same dimension as Yo indicating if each entry in Yo is non-zero, i.e. Vo = (Yo != 0).

Yo

A numerical matrix, the sample matrix for the parent nodes (regressors).

right

A string vector of length equal to ncol(Vo), the names of the parent nodes.

V_degree

A non-negative integer, the degree for the Vo in the Hurdle polynomial. Defaults to 1.

Y_degree

A non-negative integer, the degree for the Yo in the Hurdle polynomial. Defaults to 1.

Y_V_degree

A non-negative integer, the degree for interaction between Vo and Yo in the Hurdle polynomial. Defaults to 1. If equal to 1, no interaction will be included (since it would be either a pure V term or a pure Y term).

Details

A Hurdle polynomial in parents Yo is a polynomial in Yo and their 0/1 indicators Vo. The V_degree of a term that is a product of some columns of Vo only is the number of parents that appears in it. For example, V1 * V2 * V3 has V_degree equal to 3. Note that V1^p is equal to V1 for any p >= 1 so it does not make sense to include a power. The Y_degree of a term that is a product of powers of some columns of Yo only is the degree of a polynomial in its usual sense. For example, Y1^2 * Y2 * Y3^3 has Y_degree equal to 2+1+3=6. The Y_V_degree of a term that involves both some columns of Vo and some of Yo is the sum of the V_degree of the V part and the Y_degree of the Y part. For example, Y1^2 * V2 * Y3^3 * V4 * V5 has Y_V_degree equal to 2+1+3+1+1=8. The function returns a Hurdle polynomial including all possible terms with V_degree, Y_degree, Y_V_degree less than or equal to those specified. For example, if Vo and Yo has two columns and V_degree == 2, Y_degree == 2, Y_V_degree == 2, the function returns a matrix with columns V1, V2, V1*V2, Y1, Y2, Y1*Y2, Y1^2, Y2^2, Y1*V2, Y2*V1. Note that terms like V1*Y1 are not included as it is equivalent to Y1. Intercepts (a column with all 1s) are also not included.

Value

The design matrix with number of rows equal to nrow(Vo).

Examples

1
2
3
Yo <- matrix(rnorm(100) * rbinom(100, 1, 0.7), ncol=2)
full_design1(Yo != 0, Yo, c("1", "2"), V_degree=2, Y_degree=2, Y_V_degree=2)
full_design1(Yo != 0, Yo, c("1", "2"), V_degree=0, Y_degree=0, Y_V_degree=0)

sqyu/ZiDAG documentation built on Jan. 19, 2021, 4:11 p.m.