get_tree_fit {lazy.cluster}R Documentation

Calculate RSS etc for each # of clusters

Description

Calculate RSS etc for each # of clusters

Usage

get_tree_fit(data = NULL, tree = NULL, print = 1, plot = 0)

Arguments

data

data frame

tree

A class hclust object created by dhclust

print

= 1 to print the result

plot

= 1 to plot the tree with rss as the height
= 2 to plot the tree with minus twice the log likelihood as the height.

Details

Given k clusters, k=1,2,...,nrow(data), the data matrix Y can be expressed as
Y = X %*% B + E
where X is the nrow(Y) times k design matrix consisting of 1s and 0s, and B is the k times ncol(Y).
RSS associated with this model, namely,
RSS = tr( t(Y)%*%(I-P(X))%*%Y ) , where P(X)=X%*%inv(t(X)%*%)%*%t(X) will be returned.
Assuming multivariate normality of the rows of the E matrix,
minus twice the log likelihood will be returned as m2llh.

Value

A class hclust object with rss, m2llh, aic, and bic added.

Examples


# native hclust
reshc <- hclust(dist(unidimdata$y))
temp <- get_tree_fit(unidimdata$y,reshc, plot=1)

# divisive
resdhc2 <- dhclust( unidimdata, ndiv=2, plot=1, print=1, method="LS" )
temp=get_tree_fit( unidimdata, resdhc2, print=2, plot=1 )
resdhc32 <- dhclust( unidimdata, ndiv=3, plot=1, print=1, method="LS"
                   , maxclustersize=2 )
temp=get_tree_fit( unidimdata, resdhc32$tree_s, print=2, plot=1 )


[Package lazy.cluster version 0.1.2 Index]