% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/kprototypes.R
\name{lambdaest}
\alias{lambdaest}
\title{Compares Variability of Variables}
\usage{
lambdaest(
  x,
  num.method = 1,
  fac.method = 1,
  outtype = "numeric",
  verbose = TRUE
)
}
\arguments{
\item{x}{Data.frame with both numerics and factors.}

\item{num.method}{Integer 1 or 2. Specifies the heuristic used for numeric variables.}

\item{fac.method}{Integer 1 or 2. Specifies the heuristic used for factor variables.}

\item{outtype}{Specifies the desired output: either 'numeric', 'vector' or 'variation'.}

\item{verbose}{Logical whether additional information about process should be printed.}
}
\value{
\item{lambda}{Ratio of averages over all numeric/factor variables is returned. 
In case of \code{outtype = "vector"} the separate lambda for all variables is returned as the inverse of the single variables' 
variation as specified by the \code{num.method} and \code{fac.method} argument. \code{outtype = "variation"} directly returns these quantities and is not meant to be 
passed directly to \code{kproto()}.}
}
\description{
Investigation of the variables' variances/concentrations to support specification of lambda for k-prototypes clustering.
}
\details{
Variance (\code{num.method = 1}) or standard deviation (\code{num.method = 2}) of numeric variables 
and \eqn{1-\sum_i p_i^2} (\code{fac.method = 1}) or \eqn{1-\max_i p_i} (\code{fac.method = 2}) for factors is computed.
}
\examples{
# generate toy data with factors and numerics

n   <- 100
prb <- 0.9
muk <- 1.5 
clusid <- rep(1:4, each = n)

x1 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x1 <- c(x1, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x1 <- as.factor(x1)

x2 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x2 <- c(x2, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x2 <- as.factor(x2)

x3 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))
x4 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))

x <- data.frame(x1,x2,x3,x4)

lambdaest(x)
res <- kproto(x, 4, lambda = lambdaest(x))

}
\author{
\email{gero.szepannek@web.de}
}
