zi_fit: Fits a Hurdle polynomial with either abk or pms...

Description Usage Arguments Details Value Examples

View source: R/zero_est_core.R

Description

Fits a Hurdle polynomial with either abk or pms parametrization.

Usage

1
2
3
4
5
6
7
8
9
zi_fit(
  V,
  Y,
  left,
  right,
  parametrization = "pms",
  value_only = TRUE,
  control = list()
)

Arguments

V

A matrix of 0/1s, equal to Y != 0.

Y

A data matrix of the same size as V.

left

An integer between 1 and ncol(Y). The index of the variable to be fit.

right

A vector of integers between 1 and ncol(Y) different from left. Indices of the "regressors".

parametrization

A string, either "abk" (canonical) or "pms" (moment).

value_only

If TRUE, returns the minimized negative log likelihood only. Defaults to TRUE.

control

A list of arguments to be passed to zi_fit_abk(), zi_fit_pms() and zi_fit_pms_choose_degree().

Details

For "abk" parametrization, consult ?zi_fit_abk for control. For "pms" parametrization, consult ?zi_fit_pms for model fitting using Hurdle polynomials of an exact degree, or ?zi_fit_pms_choose_degree for automatically determining the degree given a maximum degree allowed.

If parametrization == "abk", calls zi_fit_abk(V, Y, left, right, value_only) with other arguments set to those in the control list. If parametrization == "pms" && is.null(control[["max_uniform_degree"]]), calls zi_fit_pms(V, Y, left, right, value_only) with other arguments set to those in the control list. If parametrization == "pms" && !is.null(control[["max_uniform_degree"]]), calls zi_fit_pms_choose_degree(V, Y, left, right, value_only) with other arguments set to those in the control list. For the list of arguments for zi_fit_abk(), zi_fit_pms() and zi_fit_pms_choose_degree(), please refer to their documentation.

Value

If value_only == TRUE, returns the minimized negative log likelihood only. Otherwise, returns

nll

A number, the minimized negative log likelihood.

par

A vector of length 4*length(right)+3, the fitted parameters, in the other of: the intercept for the a (a scalar), linear coefficients on V[,right] for a, linear coefficients on Y[,right] for a, the intercept for the b (a scalar), linear coefficients on V[,right] for b, linear coefficients on Y[,right] for b.

n

An integer, the sample size.

effective_df

4*length(right)+3, the effective degree of freedom.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
m <- 3; n <- 1000
adj_mat <- make_dag(m, "complete")
dat <- gen_zero_dat(1, "abk", adj_mat, n, k_mode=1, min_num=10, gen_uniform_degree=1)
zi_fit(dat$V, dat$Y, 3, 1:2, "abk", TRUE, list(use_C=FALSE, maxit=1000, runs=2, report=0))
zi_fit(dat$V, dat$Y, 3, 1:2, "abk", TRUE, list(use_C=TRUE, maxit=1000, runs=2, report=0))
zi_fit(dat$V, dat$Y, 3, 1:2, "abk", FALSE, list(use_C=FALSE, maxit=1000, runs=2, report=0))
zi_fit(dat$V, dat$Y, 3, 1:2, "abk", FALSE, list(use_C=TRUE, maxit=1000, runs=2, report=0))

dat <- gen_zero_dat(1, "pms", adj_mat, 1000, k_mode=1, min_num=10, gen_uniform_degree=1)
zi_fit(dat$V, dat$Y, 3, 1:2, "pms", value_only=TRUE,
    list(p_V_degree=2, p_Y_degree=2, p_Y_V_degree=2, mu_V_degree=2, mu_Y_degree=2))
zi_fit(dat$V, dat$Y, 3, 1:2, "pms", value_only=FALSE,
    list(p_V_degree=2, p_Y_degree=2, p_Y_V_degree=2, mu_V_degree=2, mu_Y_degree=2))

zi_fit(dat$V, dat$Y, 3, 1:2, "pms", value_only=TRUE,
    list(max_uniform_degree=2L, print_best_degree = TRUE))
zi_fit(dat$V, dat$Y, 3, 1:2, "pms", value_only=FALSE,
    list(max_uniform_degree=2L, print_best_degree = TRUE))

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