trajeR.POIS: Internal function to fit Poisson Model

View source: R/InternalTrajeR.R

trajeR.POISR Documentation

Internal function to fit Poisson Model

Description

Internal function to fit Poisson Model

Usage

trajeR.POIS(
  Y,
  A,
  X,
  TCOV,
  ng,
  nx,
  n,
  nbeta,
  nw,
  ntheta,
  period,
  degre,
  theta,
  beta,
  delta,
  pi,
  Method,
  hessian,
  itermax,
  paraminit,
  EMIRLS,
  refgr,
  control
)

Arguments

Y

Matrix, Formula, or a list of Formulas. A matrix containing the response variables, a single formula (e.g., Y ~ A + I(A^2)), or a list of formulas for models with different degrees.

A

Matrix. A matrix containing the time variable data. Can be omitted if specified in the RHS of the Y formula.

X

Matrix. The matrix of covariates modifying group membership probability. Includes an intercept.

TCOV

Matrix or Formula. An optional matrix (or one-sided formula) containing time-dependent covariates that influence the trajectories.

ng

Integer. The number of groups. Required if using a single formula or if 'degre' is not provided.

nx

Integer. The number of covariates.

n

Integer. Number of individuals.

nbeta

Vector of integers. Number of beta parameters for each group.

nw

Integer. Number of time-dependent covariates.

ntheta

Integer. Number of theta parameters for each group.

period

Integer. Number of measurement time points.

degre

Vector of integers. The degree of each polynomial function. The code adds 1 to these values internally.

theta

Vector of real. Initial parameters for group membership probability.

beta

List of vectors. Initial beta parameters for each group's trajectory.

delta

List of vectors. Initial delta parameters for time-dependent covariates.

pi

Vector of real. Initial group membership probabilities.

Method

String. The estimation method. "L" for Likelihood, "EM" for Expectation-Maximization.

hessian

Logical. If TRUE, the Hessian matrix is computed. Default is TRUE.

itermax

Integer. The maximum number of iterations for the optimization algorithm (like 'optim' or the EM loop). Default is 100.

paraminit

Vector. The vector of initial parameters.

EMIRLS

Logical. If TRUE, use the EM-IRLS method for estimation.

refgr

Integer. The reference group number. Default is 1.

control

A list of control parameters for the 'ucminf' optimization algorithm.

  • 'trace': If positive, detailed tracing information is printed for each iteration.

  • 'grtol': The algorithm stops when the largest absolute value of the gradient is less than 'grtol'. Default is 1e-6.

  • 'xtol': The algorithm stops when the last relative step length is sufficiently small. Default is 1e-12.

  • 'stepmax': Initial maximal allowed step length (radius of trust-region). The value is updated during the optimization. Default is 1.

  • 'maxeval': The maximum number of function evaluations (objective and gradient). Default is 500.

  • ‘grad': Method for finite difference approximation of the gradient if not provided. Can be ’forward' (default) or 'central'.

  • 'gradstep': Vector of length 2 for the step length in finite difference approximation. Default is c(1e-6, 1e-8).

Value

Returns an object of class 'Trajectory.POIS'.

  • 'beta': Vector of final beta parameters.

  • 'delta': Vector of final delta parameters (if 'nw > 0').

  • 'theta': Vector of final theta parameters for group membership.

  • 'sd': Vector of standard deviations of the parameters.

  • 'tab': A data frame with parameter estimates and statistics.

  • 'Model': The string "POIS".

  • 'groups': The number of groups.

  • 'Names': The names of the parameters.

  • 'Method': The estimation method used.

  • 'Size': The number of individuals.

  • 'Likelihood': The final log-likelihood value.

  • 'Time': The time points for the first individual.

  • 'degre': A vector with the polynomial degrees for each group.


trajeR documentation built on Aug. 4, 2026, 1:09 a.m.