Hello I have data that are categorical both independent variable and dependent as well having levels more than 3. How can i check the normality of my data?
I have tried the example given of Shapiro-Wilk for levels of factors data summary(chickwts) ## linear model and ANOVA fm <- lm(weight ~ feed, data = chickwts) anova(fm) ## QQ plot for residuals + Shapiro-Wilk test shapiro.test(residuals(fm)) ## separate tests for all groups of observations ## (with some formatting) do.call("rbind", with(chickwts, tapply(weight, feed, function(x) unlist(shapiro.test(x)[c("statistic", "p.value")])))) But ended up with Error message that x should be numeric and more comments see below. Hope to get some help on this Thanks, Nancy ## linear model and ANOVA > fm <- lm(retaliation ~ occupation, data = kazi) Warning messages: 1: In model.response(mf, "numeric") : using type = "numeric" with a factor response will be ignored 2: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors > anova(fm) Error in if (ssr < 1e-10 * mss) warning("ANOVA F-tests on an essentially perfect fit are unreliable") : missing value where TRUE/FALSE needed In addition: Warning message: In Ops.factor(object$residuals, 2) : ‘^’ not meaningful for factors > ## QQ plot for residuals + Shapiro-Wilk test > shapiro.test(residuals(fm)) Error in class(y) <- oldClass(x) : adding class "factor" to an invalid object > ## separate tests for all groups of observations > ## (with some formatting) > do.call("rbind", with(kazi, tapply(retaliation, occupation, + function(x) unlist(shapiro.test(x)[c("statistic", "p.value")])))) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.