Title: | Multivariate Nonparametric Methods. An Approach Based on Spatial Signs and Ranks |
---|---|
Description: | Multivariate tests, estimates and methods based on the identity score, spatial sign score and spatial rank score are provided. The methods include one and c-sample problems, shape estimation and testing, linear regression and principal components. The methodology is described in Oja (2010) <doi:10.1007/978-1-4419-0468-3> and Nordhausen and Oja (2011) <doi:10.18637/jss.v043.i05>. |
Authors: | Klaus Nordhausen [aut, cre] , Jyrki Mottonen [aut] , Hannu Oja [aut] |
Maintainer: | Klaus Nordhausen <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0-4 |
Built: | 2024-11-25 06:28:37 UTC |
Source: | CRAN |
Multivariate tests, estimates and methods based on the identity score, spatial sign score and spatial rank score are provided. The methods include one and c-sample problems, shape estimation and testing, linear regression and principal components.
Package: | MNM |
Type: | Package |
Title: | Multivariate Nonparametric Methods. An Approach Based on Spatial Signs and Ranks |
Version: | 1.0-4 |
Date: | 2023-11-29 |
Authors@R: | c(person("Klaus", "Nordhausen", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3758-8501")), person("Jyrki", "Mottonen", role = c("aut"), comment = c(ORCID = "0000-0002-6270-2556")), person("Hannu", "Oja", role = c("aut"), comment = c(ORCID = "0000-0002-4945-5976"))) |
Author: | Klaus Nordhausen [aut, cre] (<https://orcid.org/0000-0002-3758-8501>), Jyrki Mottonen [aut] (<https://orcid.org/0000-0002-6270-2556>), Hannu Oja [aut] (<https://orcid.org/0000-0002-4945-5976>) |
Maintainer: | Klaus Nordhausen <[email protected]> |
Depends: | R (>= 2.9.2), ICSNP, SpatialNP |
Imports: | ellipse, ICS |
Suggests: | gamlss, mvtnorm |
Description: | Multivariate tests, estimates and methods based on the identity score, spatial sign score and spatial rank score are provided. The methods include one and c-sample problems, shape estimation and testing, linear regression and principal components. The methodology is described in Oja (2010) <doi:10.1007/978-1-4419-0468-3> and Nordhausen and Oja (2011) <doi:10.18637/jss.v043.i05>. |
License: | GPL (>= 2) |
LazyLoad: | yes |
Encoding: | UTF-8 |
NeedsCompilation: | no |
Packaged: | 2023-11-29 13:04:58 UTC; admin |
Repository: | CRAN |
Date/Publication: | 2023-11-29 14:30:06 UTC |
Config/pak/sysreqs: | make |
The methods implemented here are mainly described in Oja (2010) and the package can be used to reproduce most of the examples in the book. The book will be refered to as the MNM book.
Klaus Nordhausen, Jyrki Mottonen and Hannu Oja
Maintainer: Klaus Nordhausen <[email protected]>
Oja, H. (2010), Multivariate Nonparametric Methods with R. An Approach Based on Spatial Signs and Ranks, Springer. <doi:10.1007/978-1-4419-0468-3>.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28. <doi:10.18637/jss.v043.i05>.
Function for transformations of the form or
affine.trans(X, A = diag(1, dim(X)[2]), b = rep(0, dim(X)[2]), A.sqrt = FALSE, na.action = na.fail)
affine.trans(X, A = diag(1, dim(X)[2]), b = rep(0, dim(X)[2]), A.sqrt = FALSE, na.action = na.fail)
X |
a numeric data frame or matrix with p columns. |
A |
full rank p times p matrix. |
b |
numeric vector of length p. |
A.sqrt |
logical. If |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
a matrix.
Klaus Nordhausen
data(iris) IRIS <- iris[,1:4] colMeans(IRIS) cov(IRIS) IRIS.trans <- affine.trans(IRIS, solve(cov(IRIS)), colMeans(IRIS),TRUE) colMeans(IRIS.trans) cov(IRIS.trans)
data(iris) IRIS <- iris[,1:4] colMeans(IRIS) cov(IRIS) IRIS.trans <- affine.trans(IRIS, solve(cov(IRIS)), colMeans(IRIS),TRUE) colMeans(IRIS.trans) cov(IRIS.trans)
Comparisons between nested multivariate linear models fitted by mv.l1lm
. The comparison can be based on score type of tests and Wald type of tests.
## S3 method for class 'mvl1lm' anova(object, object2 = NULL, test = "Score", ...)
## S3 method for class 'mvl1lm' anova(object, object2 = NULL, test = "Score", ...)
object |
an object of class |
object2 |
an object of class |
test |
The test to be used. Options are |
... |
needed for other methods. |
If only object
is provided the function tests if all parameters equal zero. If object
and object2
are provided the function tests the
null hypothesis that the the restricted model (object2
) is true.
For details see chapter 13 of the MNM book. Note that it is the users responsibility to make sure that the two models are nested and fitted on the same data.
For the regular L2 regression anova.mlm
provides more options.
A list with class 'anovamvl1lm' containing the following components:
models |
the model call(s) of |
method |
type of the test used. |
statistic |
value of the test statistic. |
parameter |
degrees of freedom. |
p.value |
p-value of the test. |
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28.
# creating simple data X <- cbind(rep(1,100),rmvnorm(100,c(0,0,0)) ) B <- matrix(c(4,1,1,0.5,-3,2,2,2),ncol=4, byrow=TRUE) Y <- X %*% t(B)+ rmvnorm(100,c(0,0), diag(0.2,2)) DAT <- data.frame(x1=X[,2],x2=X[,3], x3=X[,4]) FullModel <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "s", stand="i", data=DAT) RestModel <- mv.l1lm(Y ~ x1, scores= "s", stand="i", data=DAT) anova(FullModel) anova(FullModel, RestModel) anova(FullModel, RestModel, test="W")
# creating simple data X <- cbind(rep(1,100),rmvnorm(100,c(0,0,0)) ) B <- matrix(c(4,1,1,0.5,-3,2,2,2),ncol=4, byrow=TRUE) Y <- X %*% t(B)+ rmvnorm(100,c(0,0), diag(0.2,2)) DAT <- data.frame(x1=X[,2],x2=X[,3], x3=X[,4]) FullModel <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "s", stand="i", data=DAT) RestModel <- mv.l1lm(Y ~ x1, scores= "s", stand="i", data=DAT) anova(FullModel) anova(FullModel, RestModel) anova(FullModel, RestModel, test="W")
Results of a randomized block experiment in the Cook Islands involving the effect of six different treatments on plots of beans infested by the serpentine leaf miner insect.
data(beans)
data(beans)
A data frame with 24 observations on the following 5 variables.
Block
a factor with levels 1
2
3
4
.
Treatment
a factor with levels 1
2
3
4
5
6
.
y1
a numeric vector. The number of miners per leaf.
y2
a numeric vector. The weight of beans per plot (in kg).
y3
a numeric vector. 1/sin(sqrt(p)), where p is the proportion of leaves infested with borer.
The value of variable y3
in Block 4 for Treatment 2 is an estimate of a missing value.
Data courtesy of Dr. R. Fullerton.
Seber, G. A. F. (1998), Multivariate Observations, London: Arnold.
data(beans) plot(beans)
data(beans) plot(beans)
Extracts the coefficents of an mvl1lm object.
## S3 method for class 'mvl1lm' coef(object, ...)
## S3 method for class 'mvl1lm' coef(object, ...)
object |
an object of class |
... |
needed for other methods. |
Note that for rank
scores the intercept, even when specified in the model, is not considered a coefficient.
Klaus Nordhausen
Extracts the fitted values of an mvl1lm object.
## S3 method for class 'mvl1lm' fitted(object, ...)
## S3 method for class 'mvl1lm' fitted(object, ...)
object |
an object of class |
... |
needed for other methods. |
Klaus Nordhausen
Estimates the multivariate location for different score functions and their asymptotic covariance matrices in the one sample case.
mv.1sample.est(X, score = "identity", stand = "outer", maxiter = 100, eps = 1e-06, na.action = na.fail, ... )
mv.1sample.est(X, score = "identity", stand = "outer", maxiter = 100, eps = 1e-06, na.action = na.fail, ... )
X |
a numeric data frame or matrix. |
score |
the score to be used. Possible choices are |
stand |
the standardization method used. Possible choices are |
maxiter |
maximum number of iterations. Used only for |
eps |
convergence tolerance. Used only for |
... |
arguments that can be passed on to functions used for the estimation of location. |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
For identity scores the location estimate is the regular mean vector. For the spatial sign score it is the spatial median in the outer
standardization case and the Hettmansperger-Randles estimate in the inner standardization case. The rank estimate is the spatial Hodges-Lehmann estimator,
either regular (stand = "outer"
) or affine equivariant (stand = "inner"
).
Computation with outer standardization is faster than with inner standardization and especially the rank version might be slow and memory consuming.
For further details see chapters 3, 5, 6, 7 and 8 of the MNM book.
A list with class 'mvloc' containing the following components:
location |
the location estimate as a vector. |
vcov |
the asymptotic covariance matrix of the location estimate. |
est.name |
name of the location estimate. |
dname |
name of the data set. |
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28.
spatial.sign
, spatial.signrank
, spatial.median
, HR.Mest
set.seed(1) X <- rmvt(100, diag(c(1, 2, 0.5)), 3) est.Hot.X <- mv.1sample.est(X) est.SS.o.X <- mv.1sample.est(X,"s") est.SS.i.X <- mv.1sample.est(X,"s","i") est.SR.o.X <- mv.1sample.est(X,"r") est.SR.i.X <- mv.1sample.est(X,"r","i") est.SR.o.X summary(est.SR.o.X) # plotting plot(est.Hot.X, est.SS.i.X, est.SR.i.X, X) # or plot(est.Hot.X, est.SS.i.X, est.SR.i.X)
set.seed(1) X <- rmvt(100, diag(c(1, 2, 0.5)), 3) est.Hot.X <- mv.1sample.est(X) est.SS.o.X <- mv.1sample.est(X,"s") est.SS.i.X <- mv.1sample.est(X,"s","i") est.SR.o.X <- mv.1sample.est(X,"r") est.SR.i.X <- mv.1sample.est(X,"r","i") est.SR.o.X summary(est.SR.o.X) # plotting plot(est.Hot.X, est.SS.i.X, est.SR.i.X, X) # or plot(est.Hot.X, est.SS.i.X, est.SR.i.X)
Tests for multivariate location using different score functions.
mv.1sample.test(X, mu = 0, score = "identity", stand = "outer", method = "approximation", n.simu = 1000, na.action = na.fail)
mv.1sample.test(X, mu = 0, score = "identity", stand = "outer", method = "approximation", n.simu = 1000, na.action = na.fail)
X |
a numeric data frame or matrix. |
mu |
the null hypothesis value. Default is the zero vector. |
score |
the score to be used. Possible choices are |
stand |
the standardization method used. Possible choices are |
method |
method for the computation of the p-value for the spatial sign and spatial signed-rank tests.
Possible choices are |
n.simu |
number of simulated sign changes if |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
The tests provided here are the Hotelling's T^2 test, the spatial sign test and the signed-rank test and their affine invariant versions in the one sample location case.
Note that for the identity score the provided test is not the traditional Hotelling's T^2 test because here the covariance matrix is computed wrt to the null value and not wrt to the sample mean.
Use the function HotellingsT2
for the traditional version of Hotelling's T^2 test.
Details about the tests can be found in the chapters 5-8 of the MNM book.
A list with class 'htest' containing the following components:
statistic |
the value of the test statistic. |
parameter |
the degrees of freedom for the test statistic or the number of replications in the simulation. |
p.value |
the p-value for the test. |
null.value |
the specified hypothesized value of the location. |
alternative |
a character string with the value 'two.sided'. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name of the data set. |
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28.
library(mvtnorm) X <- rmvt(100, diag(c(1, 2, 0.5)), 3) mv.1sample.test(X,mu=c(0,0,0.5)) mv.1sample.test(X,score="s", stand="i") mv.1sample.test(X,score="s", stand="i", method="s") mv.1sample.test(X,score="r", stand="o") mv.1sample.test(X,score="r", stand="i")
library(mvtnorm) X <- rmvt(100, diag(c(1, 2, 0.5)), 3) mv.1sample.test(X,mu=c(0,0,0.5)) mv.1sample.test(X,score="s", stand="i") mv.1sample.test(X,score="s", stand="i", method="s") mv.1sample.test(X,score="r", stand="o") mv.1sample.test(X,score="r", stand="i")
Estimates the multivariate shift for different score functions and their asymptotic covariance matrices in the two sample case.
mv.2sample.est(X, g, score = "identity", stand = "outer", maxiter = 100, eps = 1e-06, na.action = na.fail, ...)
mv.2sample.est(X, g, score = "identity", stand = "outer", maxiter = 100, eps = 1e-06, na.action = na.fail, ...)
X |
a numeric data frame or matrix. |
g |
a factor with two levels |
score |
the score to be used. Possible choices are |
stand |
the standardization method used. Possible choices are |
maxiter |
maximum number of iterations. Used only for |
eps |
convergence tolerance. Used only for |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
... |
arguments that can be passed on to functions used for the estimation of location. |
This implements the location estimates and their asymptotic covariance matrices as described in chapter 11 of the MNM book.
Note that the shift is the parameter for the defference between 'values of level 1 - values of level 2' where the levels are as defined in the factor g
.
For the general c sample location case the function mv.l1lm
might be used.
A list with class 'mvloc' containing the following components:
location |
the location estimate as a vector. |
vcov |
the asymptotic covariance matrix of the location estimate. |
est.name |
name of the location estimate. |
dname |
name of data set for which the location was computed. |
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28.
spatial.sign
, spatial.signrank
X1<- rmvnorm(50,c(0,0,0)) X2<- rmvnorm(70,c(1,1,2)) X<-rbind(X1,X2) g<-factor(rep(1:2,c(50,70))) est.Hot.X <- mv.2sample.est(X, g) est.SS.o.X <- mv.2sample.est(X, g, "s") est.SS.i.X <- mv.2sample.est(X, g, "s", "i") est.SR.o.X <- mv.2sample.est(X, g, "r") est.SR.i.X <- mv.2sample.est(X, g, "r", "i") est.SS.o.X summary(est.SS.o.X) # plotting plotMvloc(est.Hot.X, est.SS.i.X, est.SR.i.X)
X1<- rmvnorm(50,c(0,0,0)) X2<- rmvnorm(70,c(1,1,2)) X<-rbind(X1,X2) g<-factor(rep(1:2,c(50,70))) est.Hot.X <- mv.2sample.est(X, g) est.SS.o.X <- mv.2sample.est(X, g, "s") est.SS.i.X <- mv.2sample.est(X, g, "s", "i") est.SR.o.X <- mv.2sample.est(X, g, "r") est.SR.i.X <- mv.2sample.est(X, g, "r", "i") est.SS.o.X summary(est.SS.o.X) # plotting plotMvloc(est.Hot.X, est.SS.i.X, est.SR.i.X)
The treatment effect estimates for different score functions and their asymptotic covariance matrices in the randomized complete block case.
mv.2way.est(x, block, treatment, score = c("identity", "sign", "rank"), stand = c("outer", "inner"), eps=1.0e-10, n.iter=1000, na.action = na.fail)
mv.2way.est(x, block, treatment, score = c("identity", "sign", "rank"), stand = c("outer", "inner"), eps=1.0e-10, n.iter=1000, na.action = na.fail)
x |
a numeric data frame or matrix. |
block |
a factor with at least two levels. |
treatment |
a factor with at least two levels. |
score |
the score to be used. Possible choices are
|
stand |
the standardization method used. Possible choices
are |
eps |
convergence criterion. |
n.iter |
maximum number of iterations. |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
This implements the treatment effect estimates described in chapter 12 of the MNM book.
A list of length c(c-1)/2 with class 'mvcloc' where c is the number of treatments. Each component of the list is a list with class 'mvloc' containing the following components:
location |
the adjusted treatment effect estimate when comparing the
treatment pair given in |
vcov |
the asymptotic covariance matrix of the adjusted treatment effect estimate. |
est.name |
name of the adjusted treatment effect estimate. |
dname |
the treatment pair for which the adjusted treatment effect estimate was computed. |
Jyrki Mottonen [email protected]
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
mv.2way.test
, mv.1sample.est
, mv.2sample.est
data(beans) est<-mv.2way.est(beans[,3:5],beans$Block,beans$Treatment,score="r",stand="i") summary(est)
data(beans) est<-mv.2way.est(beans[,3:5],beans$Block,beans$Treatment,score="r",stand="i") summary(est)
Multivariate tests for testing the null hypothesis that there is no treatment effect in a randomized complete block design using different scores.
mv.2way.test(x, block, treatment, score = c("identity", "sign", "rank"), stand = c("outer", "inner"), method = c("approximation", "permutation"), n.simu = 1000, eps=1.0e-10, n.iter=10000, na.action = na.fail)
mv.2way.test(x, block, treatment, score = c("identity", "sign", "rank"), stand = c("outer", "inner"), method = c("approximation", "permutation"), n.simu = 1000, eps=1.0e-10, n.iter=10000, na.action = na.fail)
x |
a numeric data frame or matrix of response variables. |
block |
a factor with at least two levels. |
treatment |
a factor with at least two levels. |
score |
the score to be used. Possible choices are
|
stand |
the standardization method used. Possible choices are
|
method |
method for the computation of the p-value for the
spatial sign and spatial rank tests. Possible choices are
|
n.simu |
number of simulated permutations if |
eps |
convergence criterion. |
n.iter |
maximum number of iterations. |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
This implements the tests described in chapter 12 of the MNM book.
A list with class 'htest' containing the following components:
statistic |
the value of the test statistic. |
parameter |
the degrees of freedom for the test statistic or the number of replications in the simulation. |
p.value |
the p-value for the test. |
null.value |
the specified null hypothesis value of the location. |
alternative |
a character string with the value 'two.sided'. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name of the data set and of the grouping vector. |
Jyrki Mottonen [email protected]
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
mv.1sample.test
, mv.Csample.test
, mv.2way.est
blocks <- gl(10, 5) treatments <- factor(rep(1:5, 10)) X <- rmvnorm(n = 50, mean = c(1,2,3), sigma = diag(3)) mv.2way.test(X, blocks, treatments, score="r", stand="i", method="a")
blocks <- gl(10, 5) treatments <- factor(rep(1:5, 10)) X <- rmvnorm(n = 50, mean = c(1,2,3), sigma = diag(3)) mv.2way.test(X, blocks, treatments, score="r", stand="i", method="a")
Several samples location tests using different scores.
mv.Csample.test(X, g, score = "identity", stand = "outer", method = "approximation", n.simu = 1000, na.action = na.fail, ...)
mv.Csample.test(X, g, score = "identity", stand = "outer", method = "approximation", n.simu = 1000, na.action = na.fail, ...)
X |
a numeric data frame or matrix of response values. |
g |
a factor with at least two levels. |
score |
the score to be used. Possible choices are |
stand |
the standardization method used. Possible choices are |
method |
method for the computation of the p-value for the spatial sign and spatial signed-rank tests.
Possible choices are |
n.simu |
number of simulated sign changes if |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
... |
arguments that can be passed on to functions used for the estimation of the spatial signs and spatial ranks. |
This implements the location tests based on identity, sign or rank scores as described in chapter 11 of the MNM book.
A list with class 'htest' containing the following components:
statistic |
the value of the test statistic. |
parameter |
the degrees of freedom for the test statistic or the number of replications in the simulation. |
p.value |
the p-value for the test. |
null.value |
the specified hypothesized value of the location. |
alternative |
a character string with the value 'two.sided'. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name of the data set and of the grouping vector. |
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28.
spatial.sign
, spatial.rank
, HotellingsT2
X <- rmvt(150,diag(1,3)) g1 <- gl(3,50) mv.Csample.test(X, g1) mv.Csample.test(X, g1, score = "s") mv.Csample.test(X, g1, score = "r") Y <- rbind(rmvnorm(40,c(0,0,0)), rmvnorm(60,c(0,0,0.4))) g2 <- factor(rep(1:2, c(40, 60))) mv.Csample.test(Y, g2, score = "r") mv.Csample.test(Y, g2, score = "r", method="p")
X <- rmvt(150,diag(1,3)) g1 <- gl(3,50) mv.Csample.test(X, g1) mv.Csample.test(X, g1, score = "s") mv.Csample.test(X, g1, score = "r") Y <- rbind(rmvnorm(40,c(0,0,0)), rmvnorm(60,c(0,0,0.4))) g2 <- factor(rep(1:2, c(40, 60))) mv.Csample.test(Y, g2, score = "r") mv.Csample.test(Y, g2, score = "r", method="p")
Tests for independence of two vectors using different scores.
mv.ind.test(X, Y, score = "identity", method = "approximation", n.simu = 1000, na.action = na.fail)
mv.ind.test(X, Y, score = "identity", method = "approximation", n.simu = 1000, na.action = na.fail)
X |
a numeric data frame or matrix. Must have the same number of rows as |
Y |
a numeric data frame or matrix. Must have the same number of rows as |
score |
the score to be used. Possible are |
method |
method for for computation of the p-value for the spatial sign and spatial signed-rank tests.
Possible are |
n.simu |
number of permutations if |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
This implements the independence tests as described in chapter 10 of the MNM book. Note that only inner test versions are implemented and that for the symmetrized sign score only the approximative method for the computation of the p-value is available.
A list with class 'htest' containing the following components:
statistic |
the value of the test statistic. |
parameter |
the degrees of freedom for the test statistic or the number of replications in the simulation. |
p.value |
the p-value for the test. |
null.value |
the specified null hypothesis value. |
alternative |
a character string with the value 'two.sided'. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name of the two data matrices. |
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28.
X <- rmvt(150,diag(1,3),df=3) Y <- rmvt(150, matrix(c(1,0.5,0.5,1),nrow=2),df=3) mv.ind.test(X, Y) mv.ind.test(X, Y, method = "p") mv.ind.test(X, Y, score = "si") mv.ind.test(X, Y, score = "si", method = "p") mv.ind.test(X, Y, score = "r") mv.ind.test(X, Y, score = "r", method = "p") mv.ind.test(X, Y, score = "sy")
X <- rmvt(150,diag(1,3),df=3) Y <- rmvt(150, matrix(c(1,0.5,0.5,1),nrow=2),df=3) mv.ind.test(X, Y) mv.ind.test(X, Y, method = "p") mv.ind.test(X, Y, score = "si") mv.ind.test(X, Y, score = "si", method = "p") mv.ind.test(X, Y, score = "r") mv.ind.test(X, Y, score = "r", method = "p") mv.ind.test(X, Y, score = "sy")
This function fits a multivariate linear regression model based on identity, spatial sign or spatial rank scores. Both inner and outer standardization are possible.
mv.l1lm(formula, scores = "identity", stand = "outer", maxiter = 1000, eps = 1e-06, eps.S = 1e-06, x = TRUE, y = TRUE, data, subset, na.action)
mv.l1lm(formula, scores = "identity", stand = "outer", maxiter = 1000, eps = 1e-06, eps.S = 1e-06, x = TRUE, y = TRUE, data, subset, na.action)
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted. The left part of the formula (the response) must be a n x p matrix with at least two columns. |
scores |
score to be used. Can be either |
stand |
can be |
maxiter |
maximum number of iterations. Used only for |
eps |
convergence tolerance. Used only for |
eps.S |
lower limit for the residual norms. Used only for |
x |
logical. Indicating whether the design matrix 'x' returned from the model matrix should be stored. Default is |
y |
logical. Indicating whether the response matrix 'y' should be stored. Default is |
data |
an optional data frame, list or environment (or object coercible by 'as.data.frame' to a data frame) containing the variables in the model. If not found in 'data', the variables are taken from 'environment(formula)', typically the environment from which 'mv.l1lm' is called. |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
a function which indicates what should happen when the data contain 'NA's. |
The theory behind this function is described in detail in Chapter 13 of the MNM book.
For regular multivariate L2-regression the function lm
might be more efficient and offers more methods. Note however that
the results given by lm
and mv.l1lm
may differ slightly due to different divisors of the covariance matrix.
The algorithms for the sign and rank scores are still in an early phase and therefore any feedback is very welcome. For example if p+1 residuals are 0, then the algorithms may not return correct values. Note also that the computations for rank scores might be slow.
Rank regression does not provide an estimate for the intercept parameter is not considered a parameter, a Hodges-Lehmann estimator of the residuals is then an estimate when an interecept term is in the formula.
For the one sample case however the function cannot be used for rank scores. We recommend that the regression function should not be used for the one or two sample case. There are
distinct functions designed for that purpose. Note furthermore that in the two sample case the covariance matrix returned from the regression function differs
slightly from the one returned by the function mv.2sample.est
since there matrix A is computed in a different way.
In general it is recommended to use the data
argument and specify there the data frame that contains the variables and matrices. For having a matrix Y in a data frame
for example the following methods work:
MyData <- data.frame(I(Y),...)
or
MyData <- data.frame(...)
MyData$Y <- Y
Otherwise also the function cbind
can be used on the left side of the formula to combine numeric vectors on the fly.
mv.l1ml
returns an object of 'class' mvl1lm
.
The functions summary
is the best choice to view the results. The
generic accessor functions coefficients
, fitted
, residuals
and vcov
extract various useful features of
the value returned by mv.l1ml
.
An object of class mv.l1ml
is a list wich contains different information depending on the scores and standardization used.
To see its content use the function str
.
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28.
lm
, mv.1sample.est
, mv.1sample.test
, mv.2sample.est
, mv.Csample.test
# creating simple data X <- cbind(rep(1,100),rmvnorm(100,c(0,0,0)) ) B <- matrix(c(4,1,1,0.5,-3,2,2,2),ncol=4, byrow=TRUE) Y <- X %*% t(B)+ rmvnorm(100,c(0,0), diag(0.2,2)) DAT <- data.frame(x1=X[,2],x2=X[,3], x3=X[,4], Y=I(Y)) # true B t(B) # example using identity scores test1 <- mv.l1lm(Y ~ x1 + x2 + x3, data=DAT) print(test1) summary(test1) coef(test1) vcov(test1) head(fitted(test1)) head(residuals(test1)) # example using outer sign scores test2 <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "s", data=DAT) print(test2) summary(test2) coef(test2) vcov(test2) head(fitted(test2)) head(residuals(test2)) # example using inner sign scores test3 <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "s", stand="i", data=DAT) print(test3) summary(test3) coef(test3) vcov(test3) head(fitted(test3)) head(residuals(test3)) # example using outer rank scores test4 <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "r", stand="o", data=DAT) print(test4) summary(test4) coef(test4) vcov(test4) head(fitted(test4)) head(residuals(test4)) # example using inner rank scores test5 <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "r", stand="i", data=DAT) print(test5) summary(test5) coef(test5) vcov(test5) head(fitted(test5)) head(residuals(test5)) # prediction newData <- data.frame(x1=c(1,-2),x2=c(0.5,0.7), x3=c(-1,-1)) newData predict(test1,newData) predict(test2,newData) predict(test3,newData) predict(test4,newData) predict(test5,newData)
# creating simple data X <- cbind(rep(1,100),rmvnorm(100,c(0,0,0)) ) B <- matrix(c(4,1,1,0.5,-3,2,2,2),ncol=4, byrow=TRUE) Y <- X %*% t(B)+ rmvnorm(100,c(0,0), diag(0.2,2)) DAT <- data.frame(x1=X[,2],x2=X[,3], x3=X[,4], Y=I(Y)) # true B t(B) # example using identity scores test1 <- mv.l1lm(Y ~ x1 + x2 + x3, data=DAT) print(test1) summary(test1) coef(test1) vcov(test1) head(fitted(test1)) head(residuals(test1)) # example using outer sign scores test2 <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "s", data=DAT) print(test2) summary(test2) coef(test2) vcov(test2) head(fitted(test2)) head(residuals(test2)) # example using inner sign scores test3 <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "s", stand="i", data=DAT) print(test3) summary(test3) coef(test3) vcov(test3) head(fitted(test3)) head(residuals(test3)) # example using outer rank scores test4 <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "r", stand="o", data=DAT) print(test4) summary(test4) coef(test4) vcov(test4) head(fitted(test4)) head(residuals(test4)) # example using inner rank scores test5 <- mv.l1lm(Y ~ x1 + x2 + x3, scores= "r", stand="i", data=DAT) print(test5) summary(test5) coef(test5) vcov(test5) head(fitted(test5)) head(residuals(test5)) # prediction newData <- data.frame(x1=c(1,-2),x2=c(0.5,0.7), x3=c(-1,-1)) newData predict(test1,newData) predict(test2,newData) predict(test3,newData) predict(test4,newData) predict(test5,newData)
Shape matrix estimates using different score functions.
mv.shape.est(X, score = "identity", estimate = "outer", location = NULL, na.action = na.fail, ...)
mv.shape.est(X, score = "identity", estimate = "outer", location = NULL, na.action = na.fail, ...)
X |
a numeric data frame or matrix. |
score |
score to be used. Can be either |
estimate |
can be |
location |
If NULL the location vector is estimated. Alternatively a numeric p vector of location. |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
... |
further arguments passed to or from other methods. |
This functions returns different shape matrices depending on the score function chosen. For details see chapter 9 of the MNM book.
a matrix
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28.
cov
, tyler.shape
, duembgen.shape
, HR.Mest
, spatial.shape
data(iris) IRIS <- iris[,1:4] mv.shape.est(IRIS, "sign") mv.shape.est(IRIS, "symmsign", "o") mv.shape.est(IRIS, "rank")
data(iris) IRIS <- iris[,1:4] mv.shape.est(IRIS, "sign") mv.shape.est(IRIS, "symmsign", "o") mv.shape.est(IRIS, "rank")
Test for sphericity based on different score functions.
mv.shape.test(X, score = "identity", location = "est", na.action = na.fail, ...)
mv.shape.test(X, score = "identity", location = "est", na.action = na.fail, ...)
X |
a numeric data frame or matrix. |
score |
the score to be used. Possible are |
location |
specifies if the location should be estimated or taken to be the origin. Possible choices are |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
... |
arguments passed on to other functions. |
Note that here inner standardization is not logical. The rank score test is not implemented. Otherwise the tests are as described in chapter 9 of the MNM book.
To test for other "shapes" than sperical, transform the data accordingly and then test for spericity.
A list with class 'htest' containing the following components:
statistic |
the value of the test statistic. |
parameter |
the degrees of freedom for the test statistic or the number of replications in the simulation. |
p.value |
the p-value for the test. |
method |
a character string indicating what type of test was performed. |
data.name |
a character string giving the name of the data used. |
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
Nordhausen, K. and Oja, H. (2011), Multivariate L1 Methods: The Package MNM, Journal of Statistical Software, 43, 1-28.
X <- rmvt(150,diag(1,3)) mv.shape.test(X) mv.shape.test(X,"sym")
X <- rmvt(150,diag(1,3)) mv.shape.test(X) mv.shape.test(X,"sym")
Principal component analysis based on different score functions
mvPCA(X, score = "identity", estimate = "outer", na.action = na.fail, ...)
mvPCA(X, score = "identity", estimate = "outer", na.action = na.fail, ...)
X |
a numeric data frame or matrix with p columns. |
score |
score to be used. Can be either |
estimate |
can be |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
... |
further arguments passed to or from other methods. |
PCA as descriped in chapter 9 of the MNM book. Note that here ALL scatter matrices used are standardized to have trace(p). This function differs from most other PCA functions in R in that it does not center the data. The 'mvPCA' class has a print, summary, plot and predict method.
A list with class 'mvloc' containing the following components:
EigenV |
the standardized eigenvalues. |
loadings |
matrix with the corresponding loadings. |
scores |
matrix with the principal components. |
dname |
name of X. |
method |
Which shape matrix was used for the computation. |
n.obs |
number of observations used. |
p |
number of variables. |
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
data(iris) IRIS <- iris[,1:4] iris.pca <- mvPCA(IRIS, "sign", "i") iris.pca summary(iris.pca) pairs(iris.pca$scores, col=iris[,5])
data(iris) IRIS <- iris[,1:4] iris.pca <- mvPCA(IRIS, "sign", "i") iris.pca summary(iris.pca) pairs(iris.pca$scores, col=iris[,5])
The function plots each variable contained in the matrix 'x' against the all variables contained in matrix 'y'. The function is not very sophisticated and only used to consider the residuals in a multivariate regression.
pairs2(x, y, mars = c(4, 4, 0.1, 0.1), ...)
pairs2(x, y, mars = c(4, 4, 0.1, 0.1), ...)
x |
a numeric matrix. Same number or rows as |
y |
a numeric matrix. Same number or rows as |
mars |
A numerical vector of the form 'c(bottom, left, top, right)'
which gives the number of lines of margin to be specified on
the four sides of the plot. The default is |
... |
Arguments to be passed to methods, such as graphical
parameters (see |
Klaus Nordhausen
X <- rmvnorm(50, c(0,0,1)) Y <- rmvnorm(50, c(20,1), matrix(rep(0.5,4),ncol=2)) colnames(X) <- LETTERS[1:3] colnames(Y) <- letters[1:2] pairs2(X,Y)
X <- rmvnorm(50, c(0,0,1)) Y <- rmvnorm(50, c(20,1), matrix(rep(0.5,4),ncol=2)) colnames(X) <- LETTERS[1:3] colnames(Y) <- letters[1:2] pairs2(X,Y)
Scatterplots of fitted vs. residual values of the response variable for an mvl1lm object.
## S3 method for class 'mvl1lm' plot(x, captation = "Residuals vs fitted", ...)
## S3 method for class 'mvl1lm' plot(x, captation = "Residuals vs fitted", ...)
x |
an object of class |
captation |
captation of the figure. |
... |
optional plotting arguments. |
Klaus Nordhausen
Visually presents and compares different multivariate location estimates and their confidence ellipsoids.
## S3 method for class 'mvloc' plot(x, est2 = NULL, est3 = NULL, X = NULL, ...)
## S3 method for class 'mvloc' plot(x, est2 = NULL, est3 = NULL, X = NULL, ...)
x |
an object of class |
est2 |
An optional additional location estimate. A list with the components |
est3 |
An optional additional location estimate. A list with the components |
X |
a numeric data frame or matrix. Optional data points on which the estimates could have been based. |
... |
optional plotting arguments. For details see |
The figure can be used to compare different multivariate location estimates. The location of the legend is currently problematic and it is
recommended that the user should provide the coordinates for the legend. The function calls plotMvloc
.
Klaus Nordhausen
X <- rmvt(50, diag(c(1, 2)), 3) est1 <- mv.1sample.est(X) est2 <- mv.1sample.est(X, "sign") est3 <- mv.1sample.est(X, "rank", "inner") plot(est1) plot(est1, est2, est3, X, alim="b", lty.ell=1:3, pch.ell=14:16) plot(est1, est2, est3, X, alim="e")
X <- rmvt(50, diag(c(1, 2)), 3) est1 <- mv.1sample.est(X) est2 <- mv.1sample.est(X, "sign") est3 <- mv.1sample.est(X, "rank", "inner") plot(est1) plot(est1, est2, est3, X, alim="b", lty.ell=1:3, pch.ell=14:16) plot(est1, est2, est3, X, alim="e")
Visually presents and compares different multivariate location estimates and their confidence ellipsoids.
plotMvloc(est1, est2 = NULL, est3 = NULL, X = NULL, alim = NULL, color.ell = 2:4, color.points = grey(0.5), lty.ell = rep(1, 3), pch.ell = rep(16, 3), lwd.ell = rep(1, 3), cex.ell = rep(1, 3), pch.points = 1, level = 0.95, npoints = 100, x.legend, y.legend, cex.legend = 1, pty = "s", gap = 1, oma.bottom, labels, cex.labels = 2, main, ...)
plotMvloc(est1, est2 = NULL, est3 = NULL, X = NULL, alim = NULL, color.ell = 2:4, color.points = grey(0.5), lty.ell = rep(1, 3), pch.ell = rep(16, 3), lwd.ell = rep(1, 3), cex.ell = rep(1, 3), pch.points = 1, level = 0.95, npoints = 100, x.legend, y.legend, cex.legend = 1, pty = "s", gap = 1, oma.bottom, labels, cex.labels = 2, main, ...)
est1 |
The location of interest. A list with the components |
est2 |
An optional additional location estimate. A list with the components |
est3 |
An optional additional location estimate. A list with the components |
X |
a numeric data frame or matrix. Optional data points on which the estimates could have been based. |
alim |
can be |
color.ell |
vector of length 3 that gives the colors for the corresponding estimates |
color.points |
the color of the data points. |
lty.ell |
line types of the confidence ellipsoids. |
pch.ell |
plotting symbols for the location estimates, the centers of the confidence ellipsoids. |
lwd.ell |
line width values of the confidence ellipsoids. |
cex.ell |
cex values for the location estimates, the centers of the confidence ellipsoids. |
pch.points |
plotting symbol for the data points |
level |
the level of the confidence ellipsoids. |
npoints |
the number of points used to approximate each ellipsoid. |
x.legend |
vertical position of the legend. By default tries to find for 2 to 4 dimensional data a good location. If |
y.legend |
horicontal position of the legend. By default tries to find for 2 to 4 dimensional data a good location. If |
cex.legend |
|
pty |
|
gap |
distance between subplots, in margin lines. |
oma.bottom |
|
labels |
optional labels for the diagonals. |
cex.labels |
|
main |
optional title of the plot. |
... |
further arguments passed to or from other methods. |
The figure can be used to compare different multivariate location estimates. The location of the legend is currently problematic and it is recommended that the user should provide the coordinates for the legend.
A scatterplot matrix.
Klaus Nordhausen
X <- rmvt(50, diag(c(1, 2)), 3) est1 <- mv.1sample.est(X) est2 <- mv.1sample.est(X, "sign") est3 <- mv.1sample.est(X, "rank", "inner") plotMvloc(est1) plotMvloc(est1, est2, est3, X, alim="b", lty.ell=1:3, pch.ell=14:16) plotMvloc(est1, est2, est3, X, alim="e")
X <- rmvt(50, diag(c(1, 2)), 3) est1 <- mv.1sample.est(X) est2 <- mv.1sample.est(X, "sign") est3 <- mv.1sample.est(X, "rank", "inner") plotMvloc(est1) plotMvloc(est1, est2, est3, X, alim="b", lty.ell=1:3, pch.ell=14:16) plotMvloc(est1, est2, est3, X, alim="e")
Function for visual comparisons for up to three shape matrices.
plotShape(est1, est2 = NULL, est3 = NULL, X = NULL, alim = NULL, color.ell = 2:4, color.points = grey(0.5), lty.ell = rep(1, 3), pch.ell = rep(16, 3), lwd.ell = rep(1, 3), cex.ell = rep(1, 3), pch.points = 1, level = 0.5, npoints = 100, x.legend, y.legend, cex.legend = 1, pty = "s", gap = 1, oma.bottom, labels, cex.labels = 2, main, ...)
plotShape(est1, est2 = NULL, est3 = NULL, X = NULL, alim = NULL, color.ell = 2:4, color.points = grey(0.5), lty.ell = rep(1, 3), pch.ell = rep(16, 3), lwd.ell = rep(1, 3), cex.ell = rep(1, 3), pch.points = 1, level = 0.5, npoints = 100, x.legend, y.legend, cex.legend = 1, pty = "s", gap = 1, oma.bottom, labels, cex.labels = 2, main, ...)
est1 |
The shape matrix of interest. A list with the components |
est2 |
An optional additional shape matrix. A list with the components |
est3 |
An optional additional shape matrix. A list with the components |
X |
a numeric data frame or matrix. Optional data points on which the estimates could have been based. |
alim |
can be |
color.ell |
vector of length 3 that gives the colors for the corresponding estimates |
color.points |
the color of the data points. |
lty.ell |
line types of the confidence ellipsoids. |
pch.ell |
plotting symbols for the location estimates, the centers of the confidence ellipsoids. |
lwd.ell |
line width values of the confidence ellipsoids. |
cex.ell |
cex values for the location estimates, the centers of the confidence ellipsoids. |
pch.points |
plotting symbol for the data points |
level |
The proportion of the data points that should be inside the ellipses. If there is no data the value for |
npoints |
the number of points used to approximate each ellipsoid. |
x.legend |
vertical position of the legend. By default tries to find for 2 to 4 dimensional data a good location. If |
y.legend |
horicontal position of the legend. By default tries to find for 2 to 4 dimensional data a good location. If |
cex.legend |
|
pty |
|
gap |
distance between subplots, in margin lines. |
oma.bottom |
|
labels |
optional labels for the diagonals. |
cex.labels |
|
main |
optional title of the plot. |
... |
further arguments passed to or from other methods. |
All scatter matrices are standardized to have determinant 1. If X
is given, the Mahalanobis distances based on the location and shape estimates are computed, and t
in the function ellipse
is the level quantile of the Mahalanobis distances. If no X
is provided t
equals level
.
The location of the legend is currently problematic and it is recommended that the user should provide the coordinates for the legend.
A scatter plot matrix.
Klaus Nordhausen
X <- rmvt(100, diag(3), df=3) EST1 <- list(location=colMeans(X), scatter=cov(X), est.name="COV") HR <- HR.Mest(X) EST2 <- list(location=HR$center, scatter=HR$scatter, est.name="Tyler") plotShape(EST1,EST2, X=X)
X <- rmvt(100, diag(3), df=3) EST1 <- list(location=colMeans(X), scatter=cov(X), est.name="COV") HR <- HR.Mest(X) EST2 <- list(location=HR$center, scatter=HR$scatter, est.name="Tyler") plotShape(EST1,EST2, X=X)
Predicted response values based on a model fitted by mv.l1lm
.
## S3 method for class 'mvl1lm' predict(object, newdata, na.action = na.pass, ...)
## S3 method for class 'mvl1lm' predict(object, newdata, na.action = na.pass, ...)
object |
an object of class |
newdata |
An optional data frame with the values of the explaining variables. If omitted, the fitted values are used. |
na.action |
function determining what should be done with missing values in 'newdata'. |
... |
needed for other methods. |
Klaus Nordhausen
Prediction method for class mvPCA.
## S3 method for class 'mvPCA' predict(object, newdata, ...)
## S3 method for class 'mvPCA' predict(object, newdata, ...)
object |
an object of class |
newdata |
New data with the same variables. If missing just the scores of object are returned. |
... |
needed for other methods. |
a matrix with the predicted principal components.
Klaus Nordhausen
Printing an object of class 'anovamvl1lm'.
## S3 method for class 'anovamvl1lm' print(x, ...)
## S3 method for class 'anovamvl1lm' print(x, ...)
x |
an object of class |
... |
needed for other methods. |
Klaus Nordhausen
Printing an mvcloc object.
## S3 method for class 'mvcloc' print(x, ...)
## S3 method for class 'mvcloc' print(x, ...)
x |
an object of class |
... |
arguments that can be passed further on. |
Jyrki Mottonen [email protected]
Printing of an mvl1lm object.
## S3 method for class 'mvl1lm' print(x, digits = 3, ...)
## S3 method for class 'mvl1lm' print(x, digits = 3, ...)
x |
an object of class |
digits |
minimal number of _significant_ digits. |
... |
needed for other methods. |
Klaus Nordhausen
Printing an mvloc object.
## S3 method for class 'mvloc' print(x, ...)
## S3 method for class 'mvloc' print(x, ...)
x |
an object of class |
... |
arguments that can be passed further on. |
Klaus Nordhausen
Prints an object of class mvPCA.
## S3 method for class 'mvPCA' print(x, ...)
## S3 method for class 'mvPCA' print(x, ...)
x |
object of type 'mvPCA' |
... |
needed for other printing methods. |
Klaus Nordhausen
Extracts the residuals of an mvl1lm object.
## S3 method for class 'mvl1lm' residuals(object, ...)
## S3 method for class 'mvl1lm' residuals(object, ...)
object |
an object of class |
... |
needed for other methods. |
Klaus Nordhausen
Function to obtain random samples from a multivariate power exponential distribution.
rmvpowerexp(n, Location = rep(0, nrow(Scatter)), Scatter = diag(length(Location)), Beta = 1)
rmvpowerexp(n, Location = rep(0, nrow(Scatter)), Scatter = diag(length(Location)), Beta = 1)
n |
number of random samples. |
Location |
Location vector of the distribution. |
Scatter |
Scatter matrix of the distribution. |
Beta |
shape parameter of the distribution. |
The power exponential distribution is an elliptical distribution which can have light or heavy tails.
Beta = 1
yields a multivariate normal distribution, Beta = 0.5
the multivariate Laplace distribution and
with increasing Beta
converges to a multivariate uniform distribution.
a matrix.
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
X1 <- rmvpowerexp(100,c(0,0,0),Beta = 0.5) pairs(X1) X2 <- rmvpowerexp(100,c(0,0,0),Beta = 1) pairs(X2) X3 <- rmvpowerexp(100,c(0,0,0),Beta = 10) pairs(X3)
X1 <- rmvpowerexp(100,c(0,0,0),Beta = 0.5) pairs(X1) X2 <- rmvpowerexp(100,c(0,0,0),Beta = 1) pairs(X2) X3 <- rmvpowerexp(100,c(0,0,0),Beta = 10) pairs(X3)
Function to sample uniformly distributed observations on the unit sphere.
runifsphere(n, p)
runifsphere(n, p)
n |
number of random samples. |
p |
dimension of the unit sphere. |
a matrix.
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.
X <- runifsphere(100,2) plot(X, pty = "s")
X <- runifsphere(100,2) plot(X, pty = "s")
Creates a screeplot for an object of class mvPCA. Works analogously to a normal screeplot for a classical principal component analysis. Here however the y-axis gives the proportion of the variation explained by the components.
## S3 method for class 'mvPCA' plot(x, main = deparse(substitute(x)), ...) ## S3 method for class 'mvPCA' screeplot(x, npcs = min(10, length(x$EigenV)), type = c("barplot", "lines"), main = deparse(substitute(x)), ...)
## S3 method for class 'mvPCA' plot(x, main = deparse(substitute(x)), ...) ## S3 method for class 'mvPCA' screeplot(x, npcs = min(10, length(x$EigenV)), type = c("barplot", "lines"), main = deparse(substitute(x)), ...)
x |
an object to type |
npcs |
the number of components to be plotted. |
type |
the type of plot. |
main |
title of the plot. |
... |
other graphical parameters passed to or from other methods. |
A screeplot.
Klaus Nordhausen
data(IRIS) IRIS <- iris[,1:4] iris.pca <- mvPCA(IRIS, "sign", "i") plot(iris.pca, type="lines")
data(IRIS) IRIS <- iris[,1:4] iris.pca <- mvPCA(IRIS, "sign", "i") plot(iris.pca, type="lines")
The function computes the spatial signs for a data set. This function differs from the function spatial.sign
in the way
how observations with small norms are treated. For details see below.
spatial.sign2(X, center = TRUE, shape = TRUE, eps.S = 1e-05, na.action = na.fail, ...)
spatial.sign2(X, center = TRUE, shape = TRUE, eps.S = 1e-05, na.action = na.fail, ...)
X |
a numeric data frame or matrix. |
center |
either a logical value or a numeric vector of length equal to the number of columns of 'X'. See below for more information. |
shape |
either a logical value or a square numeric matrix with number of columns equal to the number of columns of 'X'. See below for more information. |
eps.S |
treshold value which defines which obersvations are considered to have a small norm. |
na.action |
a function which indicates what should happen when the data contain 'NA's. Default is to fail. |
... |
arguments that can be passed on to functions used for the estimation of location and shape. |
The spatial signs U of X with location and shape V are given by transforming the data points
and then computing
If a numeric value is given as 'center' and/or 'shape' these are used as and/or V in the above formula.
If 'center' and/or 'shape' are 'TRUE' the values for
and/or V are estimated, if 'FALSE' the origin is used as the
value of
and/or the identity matrix as the value of V.
When the norm is 0 then the spatial sign is set usually to 0 as for example in the function
spatial.sign
. Here however if the spatial designs are defined as
a matrix with the spatial signs of the data as rows or the univariate signs as a px1 matrix. The centering vector and scaling matrix used are returned as attributes 'center' and 'shape'.
Klaus Nordhausen
# comparing spatial.sign and spatial.sign2 data(pulmonary) head(spatial.sign2(pulmonary, c(-0.1099999,-0.12,-4.3),FALSE)) head(spatial.sign(pulmonary, c(-0.1099999,-0.12,-4.3),FALSE))
# comparing spatial.sign and spatial.sign2 data(pulmonary) head(spatial.sign2(pulmonary, c(-0.1099999,-0.12,-4.3),FALSE)) head(spatial.sign(pulmonary, c(-0.1099999,-0.12,-4.3),FALSE))
Summarizing an 'mvcloc'
object.
## S3 method for class 'mvcloc' summary(object,..., digits = 4)
## S3 method for class 'mvcloc' summary(object,..., digits = 4)
object |
an object of class |
... |
needed for other summary methods. |
digits |
number of digits for rounding. |
Jyrki Mottonen [email protected]
Gives a detailed output for an object of class mvl1lm. Note that the output will differ for different score functions used.
## S3 method for class 'mvl1lm' summary(object, ..., digits = 3)
## S3 method for class 'mvl1lm' summary(object, ..., digits = 3)
object |
an object of class |
... |
needed for other methods. |
digits |
minimal number of _significant_ digits. |
Klaus Nordhausen
Summarizing an 'mvloc'
object.
## S3 method for class 'mvloc' summary(object,..., digits = 4)
## S3 method for class 'mvloc' summary(object,..., digits = 4)
object |
an object of class |
... |
needed for other summary methods. |
digits |
number of digits for rounding. |
Klaus Nordhausen
Summary method for an object of class mvPCA.
## S3 method for class 'mvPCA' summary(object, loadings = FALSE, cutoff = 0.1, ...) ## S3 method for class 'summary.mvPCA' print(x, digits = 3, loadings = x$print.loadings, cutoff = x$cutoff, ...)
## S3 method for class 'mvPCA' summary(object, loadings = FALSE, cutoff = 0.1, ...) ## S3 method for class 'summary.mvPCA' print(x, digits = 3, loadings = x$print.loadings, cutoff = x$cutoff, ...)
object |
an object to type |
loadings |
logical. Should the loadings be returned. |
cutoff |
numeric. Loadings below this cutoff in absolute value are shown as blank in the output. |
x |
an object of class "summary.mvPCA". |
digits |
the number of significant digits to be used in listing of loadings. |
... |
arguments to be passed to or from other methods. |
'object' with additional components 'cutoff' and 'print.loadings'.
Klaus Nordhausen
data(iris) IRIS <- iris[,1:4] iris.pca <- mvPCA(IRIS, "sign", "i") summary(iris.pca, loadings = TRUE)
data(iris) IRIS <- iris[,1:4] iris.pca <- mvPCA(IRIS, "sign", "i") summary(iris.pca, loadings = TRUE)
Extracts the variance-covariance matrix of an mvl1lm Object.
## S3 method for class 'mvl1lm' vcov(object, ...)
## S3 method for class 'mvl1lm' vcov(object, ...)
object |
an object of class |
... |
needed for other methods. |
For details see Chapter 13 of the MNM book.
Klaus Nordhausen
Oja, H. (2010), Multivariate Nonparametric Methods with R, Springer.