This function prepares a matrix with compositional variables for further
processing in the DirichletReg package.
Usage
DR_data(data, trafo = FALSE, base = 1)
## S3 method for class 'DirichletRegData':
print(x, \ldots)
getdata(object, orig = FALSE)
Arguments
data
a matrix or data.frame of all compositional variables
trafo
transform variables to shrink away from extreme values of 0 and 1
base
the `base' variable to use in the reparametrized model
x
an object generated by DR_data
...
further arguments
object
a DirichletRegData object
orig
a logical value indicating whether the original data (without
NAs) or the transformed and normalized data are returned
Value
The function returns an object of class DirichletRegData containing a list of 5 elements:
Ythe actual (possibly transformed or normalized) data
Y.origthe original data
dimsnumber of dimensions of Y (i.e. number of columns)
obsnumber of observations of Y (i.e. number of rows)
excludedis either NULL, if all observations can be used, or contains a logical vector where TRUE means the exclusion of an observation due to missing values
normalizeda logical value indicating whether the data were normalized
transformeda logical value indicating whether the data were transformed
basenumber of the variable used as the base in the reparametrized model
Details
The transformation (done if trafo is TRUE) is a generalization of
that proposed by Smithson and Verkuilen (2006) that transforms each component
$y$ of $Y$ by computing $y^{*}=\frac{y(n-1)+\frac{1}{2}}{n}$
where $n$ is the number of observations in $Y$ (this approach is used in betareg, see ).
For an arbitrary number of dimensions (or variables) $d$ the transformation
is carried out by $y^{*}=\frac{y(n-1)+\frac{1}{d}}{n}$.
References
Smithson, M. & Verkuilen, J. (2006). A Better Lemon Squeezer? Maximum-Likelihood Regression With Beta-Distributed Dependent Variables. Psychological Methods, 11(1), 54--71.
Cribari-Neto, F. & Zeileis, A. (2010). Beta Regression in R. Journal of Statistical Software, 34(2), 1--24.
# create a DirichletRegData object from the Arctic Lake dataAL <- DR_data(ArcticLake[, 1:3])
AL
# extract the original data and print the first rowshead(getdata(AL, orig = TRUE))