| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/find_dend.R |
| 3 |
\name{dend_expend} |
| 4 |
\alias{dend_expend} |
| 5 |
\alias{find_dend} |
| 6 |
\title{Finds a "good" dendrogram for a dist} |
| 7 |
\usage{ |
| 8 |
dend_expend( |
| 9 |
x, |
| 10 |
dist_methods = c("euclidean", "maximum", "manhattan", "canberra", "binary", |
| 11 |
"minkowski"), |
| 12 |
hclust_methods = c("ward.D", "ward.D2", "single", "complete", "average", "mcquitty", |
| 13 |
"median", "centroid"), |
| 14 |
hclust_fun = hclust, |
| 15 |
optim_fun = cor_cophenetic, |
| 16 |
... |
| 17 |
) |
| 18 |
|
| 19 |
find_dend(x, ...) |
| 20 |
} |
| 21 |
\arguments{ |
| 22 |
\item{x}{A matrix or a data.frame. Can also be a \link{dist} object.} |
| 23 |
|
| 24 |
\item{dist_methods}{A vector of possible \link{dist} methods.} |
| 25 |
|
| 26 |
\item{hclust_methods}{A vector of possible \link{hclust} methods.} |
| 27 |
|
| 28 |
\item{hclust_fun}{By default \link{hclust}.} |
| 29 |
|
| 30 |
\item{optim_fun}{A function that accepts a dend and a dist and returns how the two |
| 31 |
are in agreement. Default is \link{cor_cophenetic}.} |
| 32 |
|
| 33 |
\item{...}{options passed from find_dend to dend_expend.} |
| 34 |
} |
| 35 |
\value{ |
| 36 |
dend_expend: |
| 37 |
A list with three items. The first item is called "dends" and includes |
| 38 |
a dendlist with all the possible dendrogram combinations. The second is "dists" and |
| 39 |
includes a list with all the possible distance matrix combination. |
| 40 |
The third. "performance", is data.frame with three columns: dist_methods, hclust_methods, and optim. |
| 41 |
optim is calculated (by default) as the cophenetic correlation (see: \link{cor_cophenetic}) between the distance matrix and |
| 42 |
the \link{cophenetic} distance of the hclust object. |
| 43 |
|
| 44 |
find_dend: A dendrogram which is "optimal" based on the output from dend_expend. |
| 45 |
} |
| 46 |
\description{ |
| 47 |
There are many options for choosing distance and linkage functions for hclust. |
| 48 |
This function goes through various combinations of the two and helps find the one |
| 49 |
that is most "similar" to the original distance matrix. |
| 50 |
} |
| 51 |
\examples{ |
| 52 |
|
| 53 |
x <- datasets::mtcars |
| 54 |
out <- dend_expend(x, dist_methods = c("euclidean", "manhattan")) |
| 55 |
out$performance |
| 56 |
|
| 57 |
dend_expend(dist(x))$performance |
| 58 |
|
| 59 |
best_dend <- find_dend(x, dist_methods = c("euclidean", "manhattan")) |
| 60 |
plot(best_dend) |
| 61 |
} |