2
I’m getting the following error while using the function boxcox()
package MASS
:
Error in as.data.frame.default(data, optional = TRUE) :
cannot coerce class ‘"function"’ to a data.frame
I don’t understand how to solve it, follow my script:
df <- read.table("https://raw.githack.com/fsbmat/StackOverflow/master/teste.txt",header = TRUE)
names(df)[1:4] <- c("a","b","rep","y")
str(df)
df$a <- as.factor(df$a)
df$b <- as.factor(df$b)
# análise de variância
m0 <- aov(y~a*b, data=df)
summary(m0)
# checagem das pressuposições
par(mfrow=c(2,2)); plot(m0); layout(1)
#
#------------------------------------------------------------------------------------------
# testes
shapiro.test(residuals(m0))
bartlett.test(residuals(m0)~interaction(df$b,df$a))
car::leveneTest(m0)
car::leveneTest(m0, center="mean")
#------------------------------------------------------------------------------------------
# precisa-se de tranformação para normalidade e homocedasticidade
require(MASS)
boxcox(m0)
Before that, I may have another problem:
> min(df$y)
[1] -0.02980628
. https://stats.stackexchange.com/a/47297/205888– bbiasi