Faster alternative to R car::Anova for sum of square crossproduct matrix calculation for subsets of predictors
问题 I need to compute the sum of squares crossproduct matrix (indeed the trace of this matrix) in a multivariate linear model, with Y (n x q) and X (n x p). Standard R code for doing that is: require(MASS) require(car) # Example data q <- 10 n <- 1000 p <- 10 Y <- mvrnorm(n, mu = rep(0, q), Sigma = diag(q)) X <- as.data.frame(mvrnorm(n, mu = rnorm(p), Sigma = diag(p))) # Fit lm fit <- lm( Y ~ ., data = X ) # Type I sums of squares summary(manova(fit))$SS # Type III sums of squares type = 3 #