I am doing a personal project trying to learn about multivariate statistics. I downloaded a dataset (found here if you want to look). At first I wanted to do a MANOVA since I have a tutorial for doing MANOVA in RStudio but realized the data doesn’t really work for a MANOVA. So, I decided to try a multivariate linear model of predicting multiple DV scores from scores on the IV.
The DVs are mostly non-normal so I went for a robust lm using lmrob() from robustbase package.
When running the lmrob function, I keep getting the error:
Error in lmrob.S(x, y, control = control) : length(y) == n is not TRUE
I’ve checked for missing data in the columns that I’m using… there are no missing scores/observations.
Tried troubleshooting with ChatGTP but it has me going round and round in circles just checking dimensions that turn out to be fine and checking for missing data which never shows anything missing and then running the lmrob again.
Here is the code using mtcars built-in in R:
`library(robustbase)
library(tidyverse)
data(mtcars)`
Here, bind the DVs and add mpg as the IV:
outcome <- cbind(mtcars$carb, mtcars$cyl)
car_rob_mod <- robustbase::lmrob(outcome ~ mpg, data = mtcars)
Throws this error:
Error in lmrob.S(x, y, control = control) : length(y) == n is not TRUE
R version: Version 2023.06.0+421 (2023.06.0+421)
macOS 12.6.1
The fact that I can get this error on the mtcars dataset makes me think I’m using lmrob inappropriately. It was my understanding you can use it for multivariate analysis… is this not the case? Would anyone recommend a different way to go about this?
lucerdoot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.