Routines for computing with discretized model matrices as described in Wood et al. (2017) and Li and Wood (2019).
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)
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.
An n-vector of weights
n-vector of data.
coefficient vector.
A matrix whose columns are index n-vectors each selecting the rows of an X[[i]] required to create the full matrix.
The ith term has index vectors ks[i,1]:(ks[i,2]-1)
. The corresponing full model matrices are summed over.
The element of X
at which each model term starts.
How many elements of X
contribute to each term.
v[[i]]
is Householder vector for ith term, if qc[i]>0
.
if qc[i]>0
then term has a constraint.
number of threads to use
list of columns of model matrix/parameters to drop
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.
extract these rows...
weight by these weights, and sum up according to ar.stop
. Used to implement AR models.
use only columns of X corresponding to these model matrix terms (for left hand X
in XWXd
).
as lt
for right hand X
.
Coefficient covariance matrix.
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
.
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