0
$\begingroup$

#H0: Median of Female population is lesser than male population < #H1: Median of Female population is greater than male population >

wilcox.test(data$gender, data$dwelling_problems_safety, alternative="less", na.action = T)

I'm unable to interpret why p-value is 1 and what it mean, am i putting hypothesis wrong?

$\endgroup$
1
  • 1
    $\begingroup$ This is all too common a tale. Without a boxplot of dwelling_problems_safety against gender there's absolutely no way to know which direction the trend ought to be in. Always visualize your data. It's obvious one of two scenarios are playing out: 1) R has picked the wrong referent group for your one-sided test 2) the data are in complete contradiction to what you expected to see if the alternative were true. $\endgroup$
    – AdamO
    Jan 26, 2023 at 18:24

1 Answer 1

1
$\begingroup$

R is probably rounding a very large p-value to 1 (e.g., 0.99999).

But more importantly, that code is testing the location parameter of the variable gender against the location parameter of dwelling_problems_safety, i.e., you are not comparing dwelling_problems_safety between the two genders. You probably want something like, wilcox.test(dwelling_problems_safety~gender, data=data, alternative="less")

Not sure why you had the "na.option=T", I don't believe that's a valid option for that function.

$\endgroup$
4
  • $\begingroup$ You mean to say that i have used comma instead of tilda, that's why not giving the results? does it matter if i change the location of x and y? "na.option=T" is because to skip the N.A Values in dataframe. Does it matter if i put in wilcox.test(gender~ dwelling_problems_safety, data=data, alternative="less") put gender first ? $\endgroup$
    – none
    Jan 27, 2023 at 10:03
  • $\begingroup$ Yes the order matters, Y~X says you want to compare Y at different levels of X. Also, I'm pretty sure you want na.omit then, not T for na.options. $\endgroup$
    – CDGKS
    Jan 28, 2023 at 15:32
  • $\begingroup$ When i put "," it gives me right hypothesis by boxplot, which say female is more then male with the dependent variable. but when i put "~" it gives me that male is equal female which is wrong by boxplot . any idea why? $\endgroup$
    – none
    Jan 29, 2023 at 14:17
  • $\begingroup$ When you put "," it doesn't test the hypothesis you want to test, so the results are meaningless. $\endgroup$
    – CDGKS
    Jan 30, 2023 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.