Learn R Programming

mosaic (version 0.6-2)

linear.algebra: Functions for teaching linear algebra.

Description

These functions provide a formula based interface to the construction of matrices from data and for fitting. You can use them both for numerical vectors and for functions of variables in data frames. These functions are intended to support teaching basic linear algebra with a particular connection to statistics.

Usage

mat(A, data = parent.frame())

singvals(A, data = parent.frame())

dot(u, v)

Arguments

A
a formula. In mat and singvals, only the right-hand side is used.
u
a numeric vector
data
a data frame from which to pull out numerical values for the variables in the formula
...
additional arguments (currently ignored)

mat returns a model matrix

To demonstrate singularity, use singvals.

v
a numeric vector

Value

  • mat returns a matrix

    singvals gives singular values for each column in the model matrix

    dot returns the dot product of u and v

See Also

project

linearModel, which returns a function.

Examples

Run this code
a <- c(1,0,0); b <- c(1,2,3); c <- c(4,5,6); x <- rnorm(3)
dot(b,c)   # dot product
# Formula interface
mat(~a+b)
mat(~a+b+1)
mat(~length+sex, data=KidsFeet)
singvals(~length*sex*width, data=KidsFeet)

Run the code above in your browser using DataLab