# Create a Type I character costmatrix:
constant_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 0,
character_type = "unordered"
)
# Calculate g for the case of five state 0s:
calculate_g(
costmatrix = constant_costmatrix,
tip_states = c("0", "0", "0", "0", "0")
)
# Create a Type II character costmatrix:
binary_symmetric_costmatrix <- make_costmatrix(
min_state = 0,
max_state = 1,
character_type = "unordered"
)
# Calculate g for the case of two state 0s and three state 1s:
calculate_g(
costmatrix = binary_symmetric_costmatrix,
tip_states = c("0", "0", "1", "1", "1")
)
# Create a Type III character costmatrix:
unordered_costmatrix <- make_costmatrix(
min_state = 0,
max_state= 2,
character_type = "unordered"
)
# Calculate g for the case of two state 0s and three state 1s and two state 2s:
calculate_g(
costmatrix = unordered_costmatrix,
tip_states = c("0", "0", "1", "1", "1", "2", "2")
)
# Create a Type IV character costmatrix:
linear_ordered_costmatrix <- make_costmatrix(
min_state = 0,
max_state= 2,
character_type = "ordered"
)
# Calculate g for the case of two state 0s and three state 1s and two state 2s:
calculate_g(
costmatrix = linear_ordered_costmatrix,
tip_states = c("0", "0", "1", "1", "1", "2", "2")
)
# Create a Type V character costmatrix:
nonlinear_ordered_costmatrix <- convert_adjacency_matrix_to_costmatrix(
adjacency_matrix = matrix(
data = c(
0, 1, 0, 0,
1, 0, 1, 1,
0, 1, 0, 0,
0, 1, 0, 0
),
nrow = 4,
dimnames = list(0:3, 0:3)
)
)
# Calculate g for the case of two state 0s, three state 1s, two state 2s and one state 3:
calculate_g(
costmatrix = nonlinear_ordered_costmatrix,
tip_states = c("0", "0", "1", "1", "1", "2", "2", "3")
)
# Create a Type VI character costmatrix:
binary_irreversible_costmatrix <- make_costmatrix(
min_state = 0,
max_state= 1,
character_type = "irreversible"
)
# Calculate g for the case of two state 0s and three state 1s:
calculate_g(
costmatrix = binary_irreversible_costmatrix,
tip_states = c("0", "0", "1", "1", "1")
)
# Create a Type VII character costmatrix:
multistate_irreversible_costmatrix <- make_costmatrix(
min_state = 0,
max_state= 2,
character_type = "irreversible"
)
# Calculate g for the case of two state 0s and three state 1s and two state 2s:
calculate_g(
costmatrix = multistate_irreversible_costmatrix,
tip_states = c("0", "0", "1", "1", "1", "2", "2")
)
# Create a Type VIII character costmatrix:
binary_dollo_costmatrix <- make_costmatrix(
min_state = 0,
max_state= 1,
character_type = "dollo"
)
# Calculate g for the case of two state 0s and three state 1s:
calculate_g(
costmatrix = binary_dollo_costmatrix,
tip_states = c("0", "0", "1", "1", "1")
)
# Create a Type IX character costmatrix:
multistate_dollo_costmatrix <- make_costmatrix(
min_state = 0,
max_state= 2,
character_type = "dollo"
)
# Calculate g for the case of two state 0s and three state 1s and two state 2s:
calculate_g(
costmatrix = multistate_dollo_costmatrix,
tip_states = c("0", "0", "1", "1", "1", "2", "2")
)
# Create a Type X character costmatrix:
multistate_symmetric_costmatrix <- make_costmatrix(
min_state = 0,
max_state= 5,
character_type = "ordered"
)
multistate_symmetric_costmatrix$type <- "custom"
multistate_symmetric_costmatrix$costmatrix <- matrix(
data = c(
0, 1, 2, 3, 2, 3,
1, 0, 3, 2, 1, 2,
2, 3, 0, 3, 2, 1,
3, 2, 3, 0, 1, 2,
2, 1, 2, 1, 0, 1,
3, 2, 1, 2, 1, 0
),
nrow = multistate_symmetric_costmatrix$size,
ncol = multistate_symmetric_costmatrix$size,
byrow = TRUE,
dimnames = list(
multistate_symmetric_costmatrix$single_states,
multistate_symmetric_costmatrix$single_states
)
)
# Calculate g for the case of two state 0s, three state 1s, two state 2s,
# one state 3, three state 4s and two state 5s:
calculate_g(
costmatrix = multistate_symmetric_costmatrix,
tip_states = c("0", "0", "1", "1", "1", "2", "2", "3", "4", "4", "4", "5", "5")
)
# Create a Type XI character costmatrix:
binary_asymmetric_costmatrix <- make_costmatrix(
min_state = 0,
max_state= 1,
character_type = "ordered"
)
binary_asymmetric_costmatrix$type <- "custom"
binary_asymmetric_costmatrix$costmatrix <- matrix(
data = c(
0, 1,
10, 0
),
nrow = binary_asymmetric_costmatrix$size,
ncol = binary_asymmetric_costmatrix$size,
byrow = TRUE,
dimnames = list(
binary_asymmetric_costmatrix$single_states,
binary_asymmetric_costmatrix$single_states
)
)
binary_asymmetric_costmatrix$symmetry <- "Asymmetric"
# Calculate g for the case of two state 0s and three state 1s:
calculate_g(
costmatrix = binary_asymmetric_costmatrix,
tip_states = c("0", "0", "1", "1", "1")
)
# Create a Type XII character costmatrix:
multistate_asymmetric_costmatrix <- make_costmatrix(
min_state = 0,
max_state= 2,
character_type = "ordered"
)
multistate_asymmetric_costmatrix$type <- "custom"
multistate_asymmetric_costmatrix$costmatrix <- matrix(
data = c(
0, 1, 1,
1, 0, 1,
10, 10, 0
),
nrow = multistate_asymmetric_costmatrix$size,
ncol = multistate_asymmetric_costmatrix$size,
byrow = TRUE,
dimnames = list(
multistate_asymmetric_costmatrix$single_states,
multistate_asymmetric_costmatrix$single_states
)
)
multistate_asymmetric_costmatrix$symmetry <- "Asymmetric"
# Calculate g for the case of two state 0s and three state 1s and two state 2s:
calculate_g(
costmatrix = multistate_asymmetric_costmatrix,
tip_states = c("0", "0", "1", "1", "1", "2", "2")
)
Run the code above in your browser using DataLab