Last chance! 50% off unlimited learning
Sale ends in
project(x, u, ...) singvals(A, data = NULL)
dot(u, v)
mat
and singvals
,
only the right-hand side is used. In project
, both
sides are used, but the left-hand side should be a single
quantitymat
returns a matrix singvals
gives singular values for each column in
the model matrix
project
returns the projection of x
onto
u
(or its length if u
and v
are
numeric vectors and type == "length"
)
dot
returns the dot product of u
and
v
mat
returns a model matrix from a formula while
project
carries out the operation of least-squares
fitting using a singular value method. This means that
even when the matrix is singular, a solution, either
exact or least-squares, will be found. To demonstrate
singularity, use singvals
. NOTE: unlike the
standard formula expansion in lm
, these linear
algebra functions do NOT include an intercept by default.
If you want an intercept, put +1
as a term in your
formula. (See the examples.)linearModel
, which returns a function.a <- c(1,0,0); b <- c(1,2,3); c <- c(4,5,6); x <- rnorm(3)
dot(b,c) # dot product
# projection onto the 1 vector gives the mean vector
mean(x)
project(x, 1)
project(x, 1, type='length')
mat(~a+b)
mat(~a+b+1)
kids = fetchData("KidsFeet.csv")
mat(~length+sex,data=kids)
project(a~b)
project(width~length+sex,data=kids)
project(log(width)~I(length^2)+sin(length)+sex,data=kids)
singvals(~length*sex*width,data=kids)
Run the code above in your browser using DataLab