R_mstep2: Accumulate Residual Second Moments for a Covariance Update

View source: R/R_mstep2.R

R_mstep2R Documentation

Accumulate Residual Second Moments for a Covariance Update

Description

Internal interface to the registered compiled routine that accumulates residual second-moment matrices for students sharing an observation pattern. The default uses ML moments; supplying the fixed-effect covariance blocks dispatches to REML_Rm for REML adjustments.

Usage

R_mstep2(
  invsqrtW_,
  JYp_,
  loopsize_,
  patternlength_,
  rownumber_,
  ybetas_,
  etahat_,
  tempmatR_,
  JXpi_,
  JXpp_,
  JXpx_,
  JXpdim_,
  JZpi_,
  JZpp_,
  JZpx_,
  JZpdim_,
  betacov_ = NULL,
  C12_ = NULL
)

Arguments

invsqrtW_

Column matrix of observation weights on the inverse square-root scale, indexed by original observation row.

JYp_

Response column matrix for the selected observation pattern.

loopsize_

Number of students sharing the pattern.

patternlength_

Number of observations per student in this pattern.

rownumber_

One-based original row numbers for the pattern observations.

ybetas_

Column matrix of fitted fixed-effect coefficients.

etahat_

Column matrix of predicted random effects.

tempmatR_

Random-effect second-moment matrix: the covariance adjustment plus the outer product of the predicted random effects.

JXpi_, JXpp_, JXpx_, JXpdim_

Compressed sparse-column row indices, column pointers, nonzero values, and dimensions of the pattern's fixed-effects design matrix. Sparse indices and pointers are zero-based.

JZpi_, JZpp_, JZpx_, JZpdim_

Corresponding compressed sparse-column components of the pattern's random-effects design matrix.

betacov_

Optional fixed-effect block of the inverse mixed-model coefficient matrix. When supplied, dispatch to the REML update.

C12_

Optional fixed/random cross block of the inverse mixed-model coefficient matrix, required along with betacov_ for REML.

Value

A square matrix of accumulated residual second moments, with dimension patternlength_.


GPvam documentation built on Oct. 23, 2026, 1:06 a.m.