# NOT RUN {
x1 <- c(5,12,13,8,88,6)
x2 <- c(5,4,3,18,168,0)
y <- 1:6
xmat <- cbind(x1,x2)
TStoX(x1,2)
# [,1] [,2] [,3]
# [1,] 5 12 13
# [2,] 12 13 8
# [3,] 13 8 88
# [4,] 8 88 6
xy <- TStoXmv(xmat,2,y)
xy
# [,1] [,2] [,3] [,4] [,5]
# [1,] 5 5 12 4 3
# [2,] 12 4 13 3 4
# [3,] 13 3 8 18 5
# [4,] 8 18 88 168 6
lm(xy[,5] ~ xy[,-5])
# Coefficients:
# (Intercept) xy[, -5]1 xy[, -5]2 xy[, -5]3 xy[, -5]4
# -65.6 3.2 18.2 -3.2 NA
# need n > 7 here for useful lm() call, but this illustrates the idea
# }
Run the code above in your browser using DataLab