mshapiro.test Error

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:

library(geomorph)
tps <-readland.tps(file.choose("File.tps"), specID = c("ID"), readcurves = TRUE, warnmsg = T)
slides <- define.sliders(c(4:14))
gpa<-gpagen(A=tps,curves = slides, PrinAxes = TRUE, Proj = TRUE, print.progress = TRUE)
gdf <- geomorph.data.frame(gpa)
gdf$coords
datos1 <-two.d.array(gdf$coords)
datos<-as.data.frame(datos1)
library(mvnormtest)
And, finally:
mshapiro.test(datos[, 1:28])

I would really appreciate if someone could help me. Thank you in advance.

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

1 Like

It has worked! Now, I can do the mshapiro.test without any problem.

Many thanks!! :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.