Learn R Programming

MNM (version 1.0-4)

mv.l1lm: Linear Regression Based on Identity, Spatial Sign or Spatial Rank Scores

Description

This function fits a multivariate linear regression model based on identity, spatial sign or spatial rank scores. Both inner and outer standardization are possible.

Usage

mv.l1lm(formula, scores = "identity", stand = "outer", 
        maxiter = 1000, eps = 1e-06, eps.S = 1e-06, 
        x = TRUE, y = TRUE, data, subset, na.action)

Value

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.

Arguments

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 "identity", "sign" or "rank".

stand

can be "outer" or "inner".

maxiter

maximum number of iterations. Used only for score = "sign" and score = "rank".

eps

convergence tolerance. Used only for score = "sign" or score = "rank".

eps.S

lower limit for the residual norms. Used only for score = "sign" or score = "rank" in the iteration procedure to avoid to divide by a zero norm.

x

logical. Indicating whether the design matrix 'x' returned from the model matrix should be stored. Default is TRUE. Might be needed for example in the anova function.

y

logical. Indicating whether the response matrix 'y' should be stored. Default is TRUE.

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.

Author

Klaus Nordhausen

Details

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:

a)

MyData <- data.frame(I(Y),...)

or

b)

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.

References

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.

See Also

lm, mv.1sample.est, mv.1sample.test, mv.2sample.est, mv.Csample.test

Examples

Run this code
# 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)

Run the code above in your browser using DataLab