zi_fit_C: Fits the Hurdle model assuming linear abk parametrization...

Description Usage Arguments Details Value Examples

View source: R/zero_est_core.R

Description

Fits the Hurdle model assuming linear abk parametrization using C code.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
zi_fit_C(
  V,
  Y,
  left,
  right,
  maxit = 200,
  runs = 1,
  value_only = TRUE,
  verbosity = 0,
  step_size = 0.1,
  lm_tol = 0.01,
  epsabs = 1e-10,
  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".

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.

verbosity

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.

epsabs

A double, accuracy of the minimization.

maxsize

A double, the final size of the simplex.

method

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

0

Fletcher-Reeves conjugate gradient

1

Polak-Ribiere conjugate gradient

2

Vector Broyden-Fletcher-Goldfarb-Shanno method

3

Steepest descent algorithm

4

Nelder-Mead simplex

5

Vector Broyden-Fletcher-Goldfarb-Shanno method version 2

6

Simplex algorithm of Nelder and Mead version 2

7

Simplex algorithm of Nelder and Mead: random initialization

Details

Fits the Hurdle model assuming linear abk parametrization, where Y[,left] conditional on Y[,right] is a 1-d Hurdle model with respect to the sum of the Lebesgue measure and a point mass at 0 with density a*v+b*y-y^2*k/2-log(1+sqrt(2pi/k)*exp(a+b^2/(2k))), with a and b both linear functions in V[,right] and Y[,right].

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
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_C(dat$V, dat$Y, 3, 1:2, maxit=1000, runs=2, value_only=TRUE, verbosity=0)
zi_fit_C(dat$V, dat$Y, 3, 1:2, maxit=1000, runs=2, value_only=FALSE, verbosity=0)

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