Fits the same cumulative-link likelihood and mean bias-reduction equations as fastglm_ordinal() while retaining one source block and matrices whose dimensions depend on the number of coefficients. The source is read again for successive fitting evaluations. Mean bias reduction first combines the information from every block, then rereads the blocks to evaluate its adjustment using that global information.

fastglm_ordinal_streaming(
  source,
  n_chunks = NULL,
  levels = NULL,
  firth = FALSE,
  link = "logit",
  tol = 1e-08,
  maxit = 200L,
  block.size = 2048L,
  control = list(),
  nonparallel = NULL
)

Arguments

source

a fastglm_source() or a function returning a list with X, y, and optional weights and offset for a block index. Matrix blocks must omit the location intercept. Formula sources remove their model-matrix intercept automatically.

n_chunks

number of blocks when source is a function.

levels

category labels in increasing order. May be inferred from an ordered factor or the column names of a category-count matrix in the first block. Every block must retain the same category specification, including categories absent from that block.

as in fastglm_ordinal(). block.size limits temporary calculations within a supplied block; the source determines the size of the block loaded into memory.

nonparallel

predictors whose slopes may differ across thresholds. Select complete model terms with a one-sided formula for a formula source, or columns by name or index for a matrix source. All declared categories must have positive total frequency for these models.

Value

A fastglm_ordinal_stream object inheriting from fastglm_ordinal, with source and reader references, source pass counts, and the usual ordinal estimates and convergence diagnostics.

Details

The rows and values returned for each block must remain unchanged during fitting and later prediction or residual calculations. Empty blocks are not accepted; blocks with zero total frequency are allowed. Category reduction and rank checks use the complete source, so individual blocks may omit categories or have deficient predictor rank.

Storage depends on the largest source block, the number of coefficients, and block-size metadata. The source itself must also obtain blocks without retaining the complete dataset if bounded memory is required. Formula sources use their recorded predictor schema and fixed transformation basis.

Coefficients, model-based covariance, summaries, diagnostics, and Wald intervals use the usual ordinal methods. Robust and clustered covariance through fastglm_vcov() rereads the source and accumulates the same ordinary-score contributions as retained dense fits. Predictions, residuals, and weights can be returned one block at a time through a callback. Collecting their complete output requires memory proportional to the number of rows. The fitted design and response are not retained. fastglm_ordinal_assess() accumulates prediction scores and calibration over the original source; fastglm_po_test() refits common-slope hypotheses through source passes. Optional boundary rows from fastglm_diagnostics() also use one source pass. Profile intervals, general constrained coefficient-score tests, and refitting bootstrap calculations require retained observations. Average prediction contrasts can receive explicit evaluation data.

Examples

set.seed(104)
x <- matrix(rnorm(120),ncol=1,dimnames=list(NULL,"exposure"))
y <- ordered(cut(.4*x[,1]+rlogis(120),c(-Inf,-.5,.7,Inf)))
reader <- function(k) {
    i <- ((k-1)*30+1):(k*30)
    list(X=x[i,,drop=FALSE],y=y[i])
}
fit <- fastglm_ordinal_streaming(reader,4,firth=TRUE)
summary(fit)
#> Proportional-odds regression
#> 
#> Call:
#> fastglm::fastglm_ordinal_streaming(source = reader, n_chunks = 4, 
#>     firth = TRUE)
#> Estimation: mean bias reduction
#> 
#> Location coefficients (positive means higher outcomes):
#>          Estimate Std. Error z value Pr(>|z|)
#> exposure   0.2849     0.1905   1.496    0.135
#> 
#> Thresholds:
#>                                  Estimate Std. Error
#> threshold:(-Inf,-0.5]|(-0.5,0.7]  -0.2955     0.1874
#> threshold:(-0.5,0.7]|(0.7, Inf]    0.6984     0.1964
#> 
#> Uncertainty: expected Fisher information
#> Sample: 120 observations represented by 120 positive-frequency rows
#> Convergence: converged (8 iterations)
head(predict(fit))
#>      (-Inf,-0.5] (-0.5,0.7] (0.7, Inf]
#> [1,]   0.4509788  0.2383916  0.3106296
#> [2,]   0.3835952  0.2434539  0.3729509
#> [3,]   0.3825079  0.2434646  0.3740275
#> [4,]   0.4485793  0.2387110  0.3127097
#> [5,]   0.3550504  0.2429119  0.4020378
#> [6,]   0.4045082  0.2427887  0.3527031