library.blgm Submodule

Module Summary

Interfaces for the NAG Mark 30.3 blgm Chapter.

blgm - Linear Model Specification

The functions in this module provide a mechanism for specifying a linear model using a text based modelling language and are intended to be used in conjunction with the model fitting functions from other modules, for example submodule correg.

See Also

naginterfaces.library.examples.blgm :

This subpackage contains examples for the blgm module. See also the Examples subsection.

Functionality Index

Linear model

construct design matrix: lm_design_matrix()

data description: lm_describe_data()

nested model: lm_submodel()

specification from formula string: lm_formula()

Service functions

destroy a G22 handle: handle_free()

general option getting function: optget()

general option setting function: optset()

For full information please refer to the NAG Library document

https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g22/g22intro.html

Examples

naginterfaces.library.examples.blgm.lm_formula_ex.main()[source]

Example for naginterfaces.library.blgm.lm_formula().

Specify a linear model via a formula string.

Demonstrates using the Handle class.

>>> main()
naginterfaces.library.blgm.lm_formula Python Example Results.
Specify a linear model via a formula string.
Formula: 1+F2+CON+F1+F2.CON+F2.F1+CON.F1
Design matrix:
[[ 1.   0.   0.  -2.4  0.   1.  -0.  -0.   0.   0.   0.   0.  -0.  -2.4]
 [ 1.   0.   1.   0.2  0.   1.   0.   0.2  0.   0.   0.   1.   0.   0.2]
 [ 1.   0.   1.  -1.4  0.   0.  -0.  -1.4  0.   0.   0.   0.  -0.  -0. ]
 [ 1.   0.   0.  -5.4  1.   0.  -0.  -0.   0.   0.   0.   0.  -5.4 -0. ]
 [ 1.   0.   1.   0.2  0.   1.   0.   0.2  0.   0.   0.   1.   0.   0.2]
 [ 1.   1.   0.   1.4  0.   1.   1.4  0.   0.   1.   0.   0.   0.   1.4]
 [ 1.   1.   0.   6.8  0.   0.   6.8  0.   0.   0.   0.   0.   0.   0. ]
 [ 1.   1.   0.   6.7  0.   0.   6.7  0.   0.   0.   0.   0.   0.   0. ]
 [ 1.   0.   0.   5.3  0.   0.   0.   0.   0.   0.   0.   0.   0.   0. ]
 [ 1.   0.   1.  -1.3  1.   0.  -0.  -1.3  0.   0.   1.   0.  -1.3 -0. ]
 [ 1.   1.   0.  -3.6  0.   1.  -3.6 -0.   0.   1.   0.   0.  -0.  -3.6]
 [ 1.   1.   0.  -0.7  0.   1.  -0.7 -0.   0.   1.   0.   0.  -0.  -0.7]
 [ 1.   0.   0.   5.7  0.   0.   0.   0.   0.   0.   0.   0.   0.   0. ]
 [ 1.   0.   1.   2.3  0.   1.   0.   2.3  0.   0.   0.   1.   0.   2.3]
 [ 1.   1.   0.   3.3  0.   0.   3.3  0.   0.   0.   0.   0.   0.   0. ]
 [ 1.   0.   1.  -0.5  1.   0.  -0.  -0.5  0.   0.   1.   0.  -0.5 -0. ]
 [ 1.   0.   0.  -2.6  0.   0.  -0.  -0.   0.   0.   0.   0.  -0.  -0. ]
 [ 1.   1.   0.   3.7  0.   0.   3.7  0.   0.   0.   0.   0.   0.   0. ]
 [ 1.   1.   0.   0.9  0.   0.   0.9  0.   0.   0.   0.   0.   0.   0. ]
 [ 1.   0.   0.  -1.1  0.   1.  -0.  -0.   0.   0.   0.   0.  -0.  -1.1]
 [ 1.   1.   0.   2.1  1.   0.   2.1  0.   1.   0.   0.   0.   2.1  0. ]
 [ 1.   0.   1.   4.6  0.   0.   0.   4.6  0.   0.   0.   0.   0.   0. ]
 [ 1.   0.   1.   4.6  1.   0.   0.   4.6  0.   0.   1.   0.   4.6  0. ]
 [ 1.   1.   0.   5.1  0.   0.   5.1  0.   0.   0.   0.   0.   0.   0. ]
 [ 1.   0.   1.   0.9  0.   0.   0.   0.9  0.   0.   0.   0.   0.   0. ]]