zi_fit_R: 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 stats::optim.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
zi_fit_R(
  V,
  Y,
  left,
  right,
  maxit = 200,
  tol = 1e-08,
  runs = 1,
  value_only = TRUE,
  report = 10
)

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.

tol

A positive number, the tolerance passed as the pgtol 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, argument to stats::optim. If set to 1 no output is print during estimation.

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

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