Hello,
I have a quite basic question. I am trying to do a Normality test for 28 variables. So, I decided to apply the function mshapiro.test. I have written it as follows:
mshapiro.test(datos[, 1:28])
However, I get the following error: Error in mshapiro.test(datos[, 1:28]) : U[] is not a matrix with number of columns (sample size) between 3 and 5000. I don't understand what I've done wrong.
For if it helps, the steps prior to this have been:
Hi @Andy233,
Your datos object must be a matrix, not a dataframe, for the mshapiro.test() function to work. See this example taken from the help:
library(mvnormtest)
data(EuStockMarkets)
head(EuStockMarkets)
dim(EuStockMarkets)
class(EuStockMarkets)
# Matrix has to be transposed for mshapiro.test() function
# Also, here take a subset of the data to easily see what is happening
small_set <- t(EuStockMarkets[1:50, 1:4])
small_set
mshapiro.test(small_set)
So, you could try: datos <- as.matrix(datos1) but this can't be tested as we don't have your data.
HTH