zi_fit_abk: Fits a linear Hurdle conditional model with abk...

Description Usage Arguments Details Value Examples

View source: R/zero_est_core.R

Description

Fits a linear Hurdle conditional model with abk parametrization.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
zi_fit_abk(
  V,
  Y,
  left,
  right,
  use_C = TRUE,
  tol = 1e-08,
  maxit = 1000,
  runs = 2,
  value_only = TRUE,
  report = 0,
  step_size = 0.1,
  lm_tol = 0.01,
  maxsize = 1e-10,
  method = 5
)

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".

use_C

A logical. Function calls zi_fit_C() if use_C == TRUE, and otherwise calls zi_fit_R().

tol

A positive number. If use_C == FALSE the tolerance passed as the pgtol argument to stats::optim (tol argument of zi_fit_R()). If use_C == TRUE, accuracy of the minimization (epsabs argument of zi_fit_C()).

maxit

An integer, the maximum number of integers, argument to stats::optim.

runs

A positive integer, number of reruns; if larger than 1, stats::optim will be called multiple times with different initial values, and the fit that maximizes the log likelihood will be used.

value_only

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

report

An integer indicating verbosity. If use_C == FALSE, passed as report argument to zi_fit_R(), argument to stats::optim: if set to 1 no output is print during estimation. If use_C == TRUE, passed as verbosity argument to zi_fit_C(), argument to optim() in C code: a positive integer, verbosity level; if set to 0 no output is print during estimation.

step_size

A double, the step size of the first trial step. Defaults to 0.1.

lm_tol

A double, accuracy of the line minimization.

maxsize

A double, the final size of the simplex.

method

A positive integer indicating the method to use. 5 is recommended and default.

Details

A linear Hurdle conditional model with abk parametrization for the left node given those in right has log density with respect to the sum of the Lebesgue measure and a point mass at 0 equal to (in terms of y) a*v+b*y-y^2*k/2-log(1+sqrt(2pi/k)*exp(a+b^2/(2k))), where v = (y != 0), k is constant and a and b are linear functions in the values for right and their indicators. This function fits such a model using Y[,left], Y[,right] and V[,right] = (Y[,right] != 0).

If right is empty, fits an unconditional univariate Hurdle using mle1d_abk(). If use_C == TRUE, calls zi_fit_C(). If use_C == FALSE, calls zi_fit_R().

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
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_abk(dat$V, dat$Y, 3, 1:2, use_C=FALSE, maxit=1000, runs=2, value_only=TRUE, report=0)
zi_fit_abk(dat$V, dat$Y, 3, 1:2, use_C=TRUE, maxit=1000, runs=2, value_only=TRUE, report=0)
zi_fit_abk(dat$V, dat$Y, 3, 1:2, use_C=FALSE, maxit=1000, runs=2, value_only=FALSE, report=0)
zi_fit_abk(dat$V, dat$Y, 3, 1:2, use_C=TRUE, maxit=1000, runs=2, value_only=FALSE, report=0)

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