Biology Reference
In-Depth Information
+
iss = iss[i]))
+
t[i] = attr(s, "threshold")
+}
Exercises of Chap. 3
3.1 Consider the Canada data set from the vars package, which we analyzed
in Sect. 3.5.1 .
(a) Load the data set from the vars package and investigate its properties using
the exploratory analysis techniques covered in Chap. 1 .
(b) Estimate a VAR( 1 ) process for this data set.
(c) Build the auto-regressive matrix A and the constant matrix B defining the
VAR( 1 )model.
(d) Compare the results with the LASSO matrix when estimating the L 1 -
penalty with cross-validation.
(e) What can you conclude ?
(a) > data(Canada)
> summary(Canada)
(b) > var.1c = VAR(Canada, p = 1, type = "const")
(c) > coefficients = coef(var.1c)
> mat = matrix(0, 4, 5)
> pvalue = 0.05
> pos = which(coefficients$e[, "Pr(>|t|)"] < pvalue)
> mat[1, pos] = coefficients$e[pos, "Estimate"]
> pos =
+ which(coefficients$prod[, "Pr(>|t|)"] < pvalue)
> mat[2, pos] = coefficients$prod[pos, "Estimate"]
> pos =
+ which(coefficients$rw[, "Pr(>|t|)"] < pvalue)
> mat[3, pos] = coefficients$rw[pos, "Estimate"]
> pos = which(coefficients$U[, "Pr(>|t|)"] < pvalue)
> mat[4, pos] = coefficients$U[pos, "Estimate"]
> A = mat[, 1:4]
> B = matrix(mat[, 5], 4, 1)
(d) > library(lars)
> data = Canada
> x = data[-c(dim(data)[1]), ]
> fit.all = lapply(colnames(data),
+ function(gene) {
+ y = data[-c(1), gene]
+ lars(y = y, x = x, type = "lasso")
+})
Search WWH ::




Custom Search