# maybe it is helpful to use the function plot.hac to verify the
# results (see example 2)
# Example 1: 4-dim AC
Matrix = 2.5
Object = hac(AC_CLAYTON, X = Matrix, dim = 4)
# class(Object) # [1] "hac"
tree2str(Object) # [1] "(V1.V2.V3.V4)_2.5"
plot(Object, , ylim = c(-0.4, 1.25), l = 1, h = 0.35)
# Example 2: 4-dim HAC
Matrix1 = matrix(c(2, 0, 4, ~X1 + X4, ~X2, ~X3), nrow = 3, byrow = TRUE)
y = c(~X1 + X4, ~X3, ~X2)
theta = c(2, 4)
Matrix3 = matrix(c(2, 0, 0, 0, ~X1 + X4, 4, 0, 0, 0, 0, ~X2, ~X3),
nrow = 3, byrow = TRUE)
# Matrix2
# [,1] [,2] [,3] [,4]
# [1,] 2 0 0 0
# [2,] Expression 4 0 0
# [3,] 0 0 Expression Expression
Object1 = hac(HAC_CLAYTON, Matrix1)
Object2 = hac.full(HAC_CLAYTON, y, theta)
tree2str(Object1) == tree2str(Object2) # [1] TRUE
tree2str(Object1) # [1] "((X2.X3)_{4}.X1.X4)_{2}"
# Object1 and Object 2 contain identical information
Object3 = hac(HAC_CLAYTON, Matrix3)
# the plots show, that the Objects are mirrored
plot.hac(Object1)
plot.hac(Object3)
# Example 3: 6-dim HAC
Matrix = matrix(c(2, 0, 0, 0, 3, 4, 0, 0, ~X1 + X6, ~X2, ~X3, ~X4 + X5),
nrow = 3, byrow = TRUE)
# Matrix
# [,1] [,2] [,3] [,4]
# [1,] 2 0 0 0
# [2,] 3 4 0 0
# [3,] Expression Expression Expression Expression
Object = hac(HAC_CLAYTON, Matrix)
Object
plot.hac(Object)
# Example 4: 5-dim HAC
Matrix1 = matrix(c(1, 0, 0, 0, 2, 3, 0, 0, ~X1,
4, ~X4, ~X5, 0, 0, ~X2, ~X3), nrow = 4, byrow = TRUE)
Matrix2 = matrix(c(1, 0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, ~X1,
4, ~X4, ~X5, 0, 0, 0, 0, 0, 0, ~X2, ~X3, 0, 0, 0, 0), nrow = 4,
byrow = TRUE)
# Matrix2
# [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
# [1,] 1 0 0 0 0 0 0 0
# [2,] 2 3 0 0 0 0 0 0
# [3,] Expression 4 Expression Expression 0 0 0 0
# [4,] 0 0 Expression Expression 0 0 0 0
Object1 = hac(HAC_CLAYTON, Matrix1)
Object2 = hac(HAC_CLAYTON, Matrix2)
tree2str(Object1) == tree2str(Object2) # [1] TRUE
Object1
plot(Object1)
# the previous result implies, that it is not necessary to include vectors
# of 0 in the matrix
Run the code above in your browser using DataLab