1\name{splitFrame} 2\alias{splitFrame} 3\title{ 4 Split Continuous and Categorical Predictors 5} 6\description{ 7 Splits the design matrix into categorical and continuous 8 predictors. Categorical variables are variables that are \code{\link{factor}}s, 9 \code{\link{ordered}} factors, \emph{or} \code{\link{character}}. 10} 11\usage{ 12splitFrame(mf, x = model.matrix(mt, mf), 13 type = c("f","fi", "fii")) 14} 15\arguments{ 16 \item{mf}{model frame (as returned by \code{\link{model.frame}}).} 17 \item{x}{(optional) design matrix, defaulting to the derived 18 \code{\link{model.matrix}}.} 19 \item{type}{a character string specifying the split type (see details).} 20} 21\details{ 22 Which split type is used can be controlled with the setting 23 \code{split.type} in \code{\link{lmrob.control}}. 24 25 There are three split types. The only differences between the types 26 are how interactions between categorical and continuous variables are 27 handled. The extra types of splitting can be used to avoid 28 \emph{Too many singular resamples} errors. 29 30 Type \code{"f"}, the default, assigns only the intercept, categorical and 31 interactions of categorical variables to \code{x1}. Interactions of 32 categorical and continuous variables are assigned to \code{x2}. 33 34 Type \code{"fi"} assigns also interactions between categorical and 35 continuous variables to \code{x1}. 36 37 Type \code{"fii"} assigns not only interactions between categorical and 38 continuous variables to \code{x1}, but also the (corresponding) 39 continuous variables themselves. 40} 41\value{ 42 A list that includes the following components: 43 \item{x1 }{design matrix containing only categorical variables} 44 \item{x1.idx }{logical vectors of the variables considered 45 categorical in the original design matrix} 46 \item{x2 }{design matrix containing the continuous variables} 47} 48\references{ 49 Maronna, R. A., and Yohai, V. J. (2000). 50 Robust regression with both continuous and categorical predictors. 51 \emph{Journal of Statistical Planning and Inference} \bold{89}, 197--214. 52} 53\author{ 54 Manuel Koller 55} 56\seealso{ 57 \code{\link{lmrob.M.S}} 58} 59\examples{ 60data(education) 61education <- within(education, Region <- factor(Region)) 62educaCh <- within(education, Region <- as.character(Region)) 63 64## no interactions -- same split for all types: 65fm1 <- lm(Y ~ Region + X1 + X2 + X3, education) 66fmC <- lm(Y ~ Region + X1 + X2 + X3, educaCh ) 67splt <- splitFrame(fm1$model) ; str(splt) 68splC <- splitFrame(fmC$model) 69stopifnot(identical(splt, splC)) 70 71## with interactions: 72fm2 <- lm(Y ~ Region:X1:X2 + X1*X2, education) 73s1 <- splitFrame(fm2$model, type="f" ) 74s2 <- splitFrame(fm2$model, type="fi" ) 75s3 <- splitFrame(fm2$model, type="fii") 76cbind(s1$x1.idx, 77 s2$x1.idx, 78 s3$x1.idx) 79rbind(p.x1 = c(ncol(s1$x1), ncol(s2$x1), ncol(s3$x1)), 80 p.x2 = c(ncol(s1$x2), ncol(s2$x2), ncol(s3$x2))) 81} 82