dgower computes and returns the Gower distance matrix for mixed variables.
Usage
dgower(x, type = list())
Arguments
x
data matrix.
type
it is a list with components cuant, bin, nom. Each component
indicates the column position of the quantitative, binary or nominal variables, respectively.
Details
The distance between two
pairs of objects i and j is obtained as
√{2(1-s_{ij})} where s_{ij} is the Gower's similarity coefficient for mixed data. This function allows
to include missing values (as NA) and therefore calculates distances based on Gower's weighted similarity coefficient.
Value
A dist object with distance information.
Note
There is the function daisy() in cluster package which can perform the Gower distance for mixed variables. The difference is that in daisy() the distance is calculated as d(i,j)=1-s_{ij} and in dgower() it is calculated as dij=sqrt(1-s_{ij}).
Author(s)
Itziar Irigoien itziar.irigoien@ehu.es; Konputazio Zientziak eta Adimen Artifiziala, Euskal Herriko Unibertsitatea (UPV-EHU), Donostia, Spain.
Conchita Arenas carenas@ub.edu; Departament d'Estadistica, Universitat de Barcelona, Barcelona, Spain.
References
Gower, J.C. (1971). A general coefficient of similarity and some of its properties. Biometrics, 27, 857–871.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(ICGE)
Loading required package: MASS
Loading required package: cluster
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ICGE/dgower.Rd_%03d_medium.png", width=480, height=480)
> ### Name: dgower
> ### Title: Gower Distance for Mixed Variables
> ### Aliases: dgower
> ### Keywords: multivariate
>
> ### ** Examples
>
> #Generate 10 objects in dimension 6
> # Quantitative variables
> mu <- sample(1:10, 2, replace=TRUE)
> xc <- matrix(rnorm(10*2, mean = mu, sd = 1), ncol=2, byrow=TRUE)
>
> # Binary variables
> xb <- cbind(rbinom(10, 1, 0.1), rbinom(10, 1, 0.5), rbinom(10, 1, 0.9))
>
> # Nominal variables
> xn <- matrix(sample(1:3, 10, replace=TRUE), ncol=1)
>
> x <- cbind(xc, xb, xn)
>
> # Distances
> d <- dgower(x, type=list(cuant=1:2, bin=3:5, nom=6))
>
>
>
>
>
>
>
> dev.off()
null device
1
>