Skip to contents

A column of ones may be added

Usage

EnsureIntercept(x)

Arguments

x

Input matrix

Value

The input matrix possibly with a column of ones added

Author

Øyvind Langsrud

Examples

x <- matrix(c(5, 8, 4, 2, 7, 6), 3, 2)
EnsureIntercept(x)
#>      [,1] [,2] [,3]
#> [1,]    1    5    2
#> [2,]    1    8    7
#> [3,]    1    4    6
EnsureIntercept(cbind(x, 2))
#>      [,1] [,2] [,3]
#> [1,]    5    2    2
#> [2,]    8    7    2
#> [3,]    4    6    2
EnsureIntercept(cbind(x, 0))
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    5    2    0
#> [2,]    1    8    7    0
#> [3,]    1    4    6    0
EnsureIntercept(matrix(0, 4, 0))
#>      [,1]
#> [1,]    1
#> [2,]    1
#> [3,]    1
#> [4,]    1