tridiag: Tridiagonal matrix

View source: R/stats.R

tridiagR Documentation

Tridiagonal matrix

Description

Make a tridiagonal matrix.

Usage

tridiag(main, upper, lower, as.covar = FALSE)

Arguments

main

vector for the main diagonal

upper

vector for the upper diagonal

lower

vector for the lower diagonal

as.covar

if TRUE, the matrix is interpreted as a variance-covariance matrix, with main giving the variances, and upper giving the correlations (the covariance will be deduced)

Value

matrix

Author(s)

Jthorpe (https://stackoverflow.com/a/28974577/597069)

Examples

## Not run: main <- 3:6
upper <- 1:3
lower <- 2:4
tridiag(main, upper, lower)

main <- sample(x=1:2, size=4, replace=TRUE)
upper <- lower <- rep(-0.4, 3)
tridiag(main, upper, lower)

## End(Not run)

timflutre/rutilstimflutre documentation built on Feb. 7, 2024, 8:17 a.m.