rg.mvalloc | R Documentation |
Function to allocate an individual to one of several populations.
rg.mvalloc(pcrit = 0.05, x, ...)
pcrit |
When the probability of group membership is less than pcrit it is allocated to group 0. |
x |
contains the individuals to be allocated |
... |
arguments for creating a list of groups |
m objects are the reference populations generated by md.gait, rg.robmva or rg.mva to estimate Mahalanobis distancesand predicted probabilities of group membership for individuals in matrix x. Note that the log |determinant| of the appropriate covariance matrix is added to the Mahalanobis distance on the assumption that the covariance matrices are inhomogeneous. If the data require transformation this must be undertaken before calling this function. This implies that a similar transformation must have been used for all the reference data subsets.
groups |
the groups |
m |
number of groups |
n |
number of individuals to be allocated |
p |
number of columns |
pgm |
number of individuals to be allocated multiplied with the groups |
pcrit |
critical probability |
xalloc |
number of individuals as integer |
Peter Filzmoser <P.Filzmoser@tuwien.ac.at> http://cstat.tuwien.ac.at/filz/
C. Reimann, P. Filzmoser, R.G. Garrett, and R. Dutter: Statistical Data Analysis Explained. Applied Environmental Statistics with R. John Wiley and Sons, Chichester, 2008.
#input data
data(ohorizon)
vegzn=ohorizon[,"VEG_ZONE"]
veg=rep(NA,nrow(ohorizon))
veg[vegzn=="BOREAL_FOREST"] <- 1
veg[vegzn=="FOREST_TUNDRA"] <- 2
veg[vegzn=="SHRUB_TUNDRA"] <- 3
veg[vegzn=="DWARF_SHRUB_TUNDRA"] <- 3
veg[vegzn=="TUNDRA"] <- 3
el=c("Ag","Al","As","B","Ba","Bi","Ca","Cd","Co","Cu","Fe","K","Mg","Mn",
"Na","Ni","P","Pb","Rb","S","Sb","Sr","Th","Tl","V","Y","Zn")
x <- log10(ohorizon[!is.na(veg),el])
v <- veg[!is.na(veg)]
res.zone1=rg.mva(as.matrix(x[v==1,]))
res.zone2=rg.mva(as.matrix(x[v==2,]))
res.zone3=rg.mva(as.matrix(x[v==3,]))
res=rg.mvalloc(pcrit=0.01,x,res.zone1,res.zone2,res.zone3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.