kruskal wallis and post hoc testing

this is my dataset:

I have three alcohol concentrations (0,1,2) and four different qualitative grades (1, 2, 3 and 4) that I've assigned to embryos after ISH.

To show a different between the concentrations, I did a Kruskal Wallis test which gave me a p-value of 4.34e-06 (this seems quite low?). Was this the right test to use?

Also, what function/test should I use for a post hoc test to analyse between 0%:1%, 0%:2% and 1%:2%? I've tried dunn methods and wilcox.test but neither will work on my data.

The first error says that your alcoholpercentage variable is not numeric. So maybe try converting it to numeric first(and check that this does not result in changes in data - like NA values etc.). The second error is probably due R "remembers" the levels in factor even when you subset the data. Use droplevels or a similar function to get rid of it. For better assesment of your problems either attach a sample of your data, if possible or make a reproducible example if not.

thanks for your response!
I'm not sure how to attach my data. The table above is the data I'm using for this.

I don't understand why i would change alcohol percentage into numeric when it's ordinal but I tried anyway and i changed the alcohol percentage to numeric and the formula still didn't work.

this is my coding:
#changing variables to categorical
conc_analysis$embryograding<- as.factor(conc_analysis$embryograding)

conc_analysis$alcoholpercentage<- as.factor(conc_analysis$alcoholpercentage)

kruskal.test(conc_analysis$alcoholpercentage ~ conc_analysis$embryograding)

#post hoc testing

wilcox.test(alcoholpercentage ~ embryograding,
data = conc_analysis,

dunnTest(alcoholpercentage ~ embryograding,
data = conc_analysis,

do i have to change the embryo grading variable to an ordinal variable rather than using the <- as.factor function?

Your alcoholpercentage variable should not be factor, but numeric instead (I assume it is the dependent variable). embryograding should be factor. Check out some info on variable types in R, for example.

This topic was automatically closed 21 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.