Last data update: 2014.03.03

R: Class "modelMatrix" and SubClasses
modelMatrix-classR Documentation

Class "modelMatrix" and SubClasses

Description

The class "modelMatrix" and notably its subclass "dsparseModelMatrix" are used to encode additional information, analogously to what the standard R function model.matrix() returns.

Objects from the Classes

Only "dsparseModelMatrix" and "ddenseModelMatrix" are “actual” (aka non-virtual) classes. For these, objects can be created by calls of the form new("dsparseModelMatrix", x, assign, contrast), where x is a dgCMatrix classed object.

Slots

The "modelMatrix" mother class contains Matrix plus two extra slots,

assign:

"integer" vector of length ncol(.), coding the variables which make up the matrix columns, see model.matrix.

contrasts:

a named list of contrasts, as in model.matrix().

Dim:

integer vector of length two with the matrix dimensions.

Dimnames:

list of length two, the dimnames(.) of the matrix.

whereas the (current only) actual classes "d*ModelMatrix", have an at least an additional (numeric slot "x". E.g., "dsparseModelMatrix" has the additional slots

i,p:

row number and “pointer” integer vectors, see class "dgCMatrix".

x:

"numeric" vector of non-zero entries.

factors:

a (possibly empty) list of factorizations.

Extends

"dsparseModelMatrix" extends class "dgCMatrix" directly,
"ddenseModelMatrix" extends class "dgeMatrix" directly.

Methods

show

signature(object = "modelMatrix"): show(.) the matrix, but also the assign and contrasts slots.

print

signature(x = "modelMatrix"): as show(), however (via ...) allowing to pass further arguments for printing the matrix.

Author(s)

Martin Maechler

See Also

sparse.model.matrix will return a "dsparseModelMatrix" object. model.Matrix which is a simple wrapper around the traditional model.matrix and returns a "ddenseModelMatrix" object.

Examples

showClass("modelMatrix")
showClass("dsparseModelMatrix")

## see   example(model.Matrix)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MatrixModels)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MatrixModels/modelMatrix-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: modelMatrix-class
> ### Title: Class "modelMatrix" and SubClasses
> ### Aliases: modelMatrix-class denseModelMatrix-class
> ###   ddenseModelMatrix-class sparseModelMatrix-class
> ###   dsparseModelMatrix-class show,modelMatrix-method
> ###   print,modelMatrix-method
> ### Keywords: classes
> 
> ### ** Examples
> 
> showClass("modelMatrix")
Virtual Class "modelMatrix" [package "MatrixModels"]

Slots:
                                              
Name:     assign contrasts       Dim  Dimnames
Class:   integer      list   integer      list

Extends: 
Class "Matrix", directly
Class "mMatrix", by class "Matrix", distance 2

Known Subclasses: "sparseModelMatrix", "denseModelMatrix"
> showClass("dsparseModelMatrix")
Class "dsparseModelMatrix" [package "MatrixModels"]

Slots:
                                                                            
Name:          i         p       Dim  Dimnames         x   factors    assign
Class:   integer   integer   integer      list   numeric      list   integer
                
Name:  contrasts
Class:      list

Extends: 
Class "dgCMatrix", directly
Class "sparseModelMatrix", directly
Class "CsparseMatrix", by class "dgCMatrix", distance 2
Class "dsparseMatrix", by class "dgCMatrix", distance 2
Class "generalMatrix", by class "dgCMatrix", distance 2
Class "dCsparseMatrix", by class "dgCMatrix", distance 2
Class "modelMatrix", by class "sparseModelMatrix", distance 2
Class "dMatrix", by class "dgCMatrix", distance 3
Class "sparseMatrix", by class "dgCMatrix", distance 3
Class "compMatrix", by class "dgCMatrix", distance 3
Class "Matrix", by class "sparseModelMatrix", distance 3
Class "xMatrix", by class "dgCMatrix", distance 4
Class "mMatrix", by class "sparseModelMatrix", distance 4
> 
> ## see   example(model.Matrix)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>