Learn R Programming

mgcv (version 1.8-29)

XWXd: Internal functions for discretized model matrix handling

Description

Routines for computing with discretized model matrices as described in Wood et al. (2017) and Li and Wood (2019).

Usage

XWXd(X,w,k,ks,ts,dt,v,qc,nthreads=1,drop=NULL,ar.stop=-1,ar.row=-1,ar.w=-1,
     lt=NULL,rt=NULL)
XWyd(X,w,y,k,ks,ts,dt,v,qc,drop=NULL,ar.stop=-1,ar.row=-1,ar.w=-1,lt=NULL)
Xbd(X,beta,k,ks,ts,dt,v,qc,drop=NULL,lt=NULL)
diagXVXd(X,V,k,ks,ts,dt,v,qc,drop=NULL,nthreads=1,lt=NULL,rt=NULL)

Arguments

X

A list of the matrices containing the unique rows of model matrices for terms of a full model matrix, or the model matrices of the terms margins. if term subsetting arguments lt and rt are non-NULL then this requires an "lpip" attribute: see details.

w

An n-vector of weights

y

n-vector of data.

beta

coefficient vector.

k

A matrix whose columns are index n-vectors each selecting the rows of an X[[i]] required to create the full matrix.

ks

The ith term has index vectors ks[i,1]:(ks[i,2]-1). The corresponing full model matrices are summed over.

ts

The element of X at which each model term starts.

dt

How many elements of X contribute to each term.

v

v[[i]] is Householder vector for ith term, if qc[i]>0.

qc

if qc[i]>0 then term has a constraint.

nthreads

number of threads to use

drop

list of columns of model matrix/parameters to drop

ar.stop

Negative to ignore. Otherwise sum rows (ar.stop[i-1]+1):ar.stop[i] of the rows selected by ar.row and weighted by ar.w to get ith row of model matrix to use.

ar.row

extract these rows...

ar.w

weight by these weights, and sum up according to ar.stop. Used to implement AR models.

lt

use only columns of X corresponding to these model matrix terms (for left hand X in XWXd).

rt

as lt for right hand X.

V

Coefficient covariance matrix.

Details

These functions are really intended to be internal, but are exported so that they can be used in the initialization code of families without problem. They are primarily used by bam to implement the methods given in the references. XWXd produces \(X^TWX\), XWy produces \(X^TWy\), Xbd produces \(X\beta\) and \(diagXVXd\) produces the diagonal of \(XVX^T\).

The "lpip" attribute of X is a list of the coefficient indices for each term. Required if subsetting via lt and rt.

References

Wood, S.N., Li, Z., Shaddick, G. & Augustin N.H. (2017) Generalized additive models for gigadata: modelling the UK black smoke network daily data. Journal of the American Statistical Association. 112(519):1199-1210 http://dx.doi.org/10.1080/01621459.2016.1195744

Li, Z & S.N. Wood (2019) Faster model matrix crossproducts for large generalized linear models with discretized covariates. Statistics and Computing. https://doi.org/10.1007/s11222-019-09864-2