I am doing a Wilcoxon rank sum test (aka Wilcoxon-Mann-Whitney) with R. There are two variables "ScorePerView", that is metric and "HasCodeElement", that is binary.  So the syntax is like that      wilcox.test(ScorePerView ~ HasCodeElement, data=Datenmatrix, paired=FALSE, alternative='less')    When the result is significant (p-value &lt; 0.005), then one distribution is lower or equal to the other.  But which one is lower? Is the one where HasCodeElement is 0 is lower (or equal) then the one where HasCodeElement is 1. Or is it the other way where HasCodeElement is 1 is lower (or equal) then the one where HasCodeElement is 0.  How can I interpret the R output on an one tailed test?  Here is my result with the syntax above.    Found the answer here:   Also marked the Question as duplicated.
120474
Say we have the following data:  set.seed(123) data &lt;- data.frame(x = c(rnorm(50, 1, 1), rnorm(50, 5, 2)),                    y = c(rep('A', 50),    rep('B', 50)))   Which yields the following boxplot (boxplot(data$x ~ data$y)):    Now let's say I want to test if the two samples have the same location parameters (median and/or mean). In my real case, the data are clearly not normal, so I've decided to run the Wilcoxon-Mann-Whitney test, like this:  wilcox.test(data$x ~ data$y)   However, I would like the alternative hypothesis to be that B, data$y's "second" factor, comes from a distribution with higher position parameters. I've tried setting the alternative parameter to "greater" and "less", but apparently the alternative hypotheses are not what I'm looking for. For example, alternative = "greater" tells me "alternative hypothesis: true location shift is greater than 0"; alternative = "less" tells me "alternative hypothesis: true location shift is less than 0".  How can I tweak the wilcox.test() function in order to have the alternative hypothesis I want (B comes from a distribution with higher position parameters than A)? Or should I just use another test instead?
107190
I am working on a very large data set, where I am comparing 2 genes. Currently I am trying to test  H0: correlation = 0.64   HA: correlation > 0.64 at the alpha = 0.05 level.   At first I thought I could use cor.test() or cor() with an argument to set the 0.64, but I am not seeing that as an option.  I'm not really sure where to go with this.
64709
I have conducted an experiment with multiple (categorical) conditions per subject, and multiple subject measurements.  My data-frame in short: A subject has one property, is_frisian which is either 0 or 1 depending on the subject. And it is tested for two conditions, person and condition. The measurement variable is error, which is either 0 or 1.  My mixed linear model in R is:  &gt; model &lt;- lmer(error~is_frisian*condition*person+(1|subject_id), data=output)   However, the residuals plot of this model gives an unexpected (?) result.    I was taught that this plot should show randomly scattered points, and they should be normal distributed. When plotting the density of the fitted and the residuals, it shows a reasonable normal distribution. The lines you can see in the graph, however, how is this to be explained? And is this okay?  The only thing I could come up with is that the graph has two lines due to the categorical variables. The output variable error is either 0 or 1. But I do not have that much knowledge of the underlying system to confirm this. And then again, the lines also seem to have a low negative slope, is this then perhaps a problem?  UPDATE:  &gt; model &lt;- glmer(error~is_frisian*condition*person + (1|subject_id), data=output, family='binomial') &gt; binnedplot(fitted(model),resid(model))   Gives the following result:    FINAL EDIT:  The density-plots have been omitted, they have nothing to do with satisfaction of assumptions in this case. For a list of assumptions on logistic regression (when using family=binomial),
17973
I recently came across the paper . The author raised a few common misconceptions regarding hypothesis testing and p-values, about which I have two specific questions:   The p-value is technically $P({\rm observation}|H_{0})$, which, as pointed out by the paper, generally does not tell us anything about $P(H_{0}|{\rm observation})$, unless we happen to know the marginal distributions, which is rarely the case in "everyday" hypothesis testing. When we obtain a small p-value and "reject the null hypothesis," what exactly is the probabilistic statement that we are making, since we cannot say anything about $P(H_{0}|{\rm observation})$? The second question relates to a particular statement from page 6(652) of the paper:      Since the p-value, or range of p-values indicated by stars, is not set a priori, it is not the long-run probability of making a Type I error but is typically treated as such.   Can anyone help to explain what is meant by this statement?
9302
Following on from my earlier posts, as far as I can understand, if I have three correlation coefficients, I will have to test them in pairs to see if there is a significant difference among them.   This means that I would have to use Fishers transformation to work out the z score of r and then the p value of z (which the recommended calculators in the earlier posts do, thankfully) and then ascertain if the p value is higher or lower than my alpha value (0.05) for each pair.  i.e. If 21 to 30 years olds is Age Group 1, 31 to 40 years is Age Group 2, and 41 to 50 years is Age Group 2, my comparison of the correlations between their shopping habits and weight loss would be:   Group 1 vs. Group 2 Group 1 vs. Group 3 Group 2 vs. Group 3   Instead of doing three separate calculations, is there a way to do all these calculations in a single step?
38551
I compared two unequal sized samples, N1 = 230 and N2 = 120 using a Mann-Whitney U test. The U is shown to be large such as 2829.   The p value is non-significant but I want to know if such large values of U is ok? Or is there something wrong there? I am using PAST software.
24852
I have four numeric variables. All of them are measures of soil quality. Higher the variable, higher the quality. The range for all of them is different:  Var1 from 1 to 10  Var2 from 1000 to 2000  Var3 from 150 to 300  Var4 from 0 to 5  I need to combine four variables into single soil quality score which will successfully rank order.  My idea is very simple. Standardize all four variables, sum them up and whatever you get is the score which should rank-order. Do you see any problem with applying this approach. Is there any other (better) approach that you would recommend?  Thanks  Edit:  Thanks guys. A lot of discussion went into "domain expertise"... Agriculture stuff... Whereas I expected more stats-talk. In terms of technique that I will be using... It will probably be simple z-score summation + logistic regression as an experiment. Because vast majority of samples has poor quality 90% I'm going to combine 3 quality categories into one and basically have binary problem (somequality vs no-quality). I kill two birds with one stone. I increase my sample in terms of event rate and I make a use of experts by getting them to clasify my samples. Expert classified samples will then be used to fit log-reg model to maximize level of concordance / discordance with the experts.... How does that sound to you?
10047
Using the inference of mean as an example, the null and alternative hypothesis could be  $$H_0: \mu \le 0 \Leftrightarrow H_1: \mu &gt; 0$$  It is often argued that this makes the calculation of the $p$-value (or critical region) easier, but from my understanding the $p$-value is $P(\bar{X} &gt; 0|H_0) \stackrel{\color{red}{?}}{=} \sup_{\theta \in H_0} P(\bar{X} &gt; 0 | \theta )$. Since I'm taking its supremum, the $p$-value doesn't change regardless of whether the equality sign is included. The same result goes for the critical region. However, I'm not sure if my understanding is correct, and my doubt is marked with a red question mark above.  Anyway, I wonder if it's correct (I know that would be unconventional, though) to write  $$H_0: \mu &lt; 0 \Leftrightarrow H_1: \mu \ge 0$$  If that's OK, what about its $p$-value and critical region? If that's not OK, I would be really surprised, because in that way we are changing the question ("Is $\mu$ less than or equal to zero?") to something different ("Is $\mu$ less than zero?")
117961
I know this is a fairly specific R question, but I may be thinking about proportion variance explained, $R^2$, incorrectly. Here goes.  I'm trying to use the R package randomForest. I have some training data and testing data. When I fit a random forest model, the randomForest function allows you to input new testing data to test. It then tells you the percentage of variance explained in this new data. When I look at this, I get one number.  When I use the predict() function to predict the outcome value of the testing data based on the model fit from the training data, and I take the squared correlation coefficient between these values and the actual outcome values for the testing data, I get a different number. These values don't match up.   Here's some R code to demonstrate the problem.  # use the built in iris data data(iris)  #load the randomForest library library(randomForest)  # split the data into training and testing sets index &lt;- 1:nrow(iris) trainindex &lt;- sample(index, trunc(length(index)/2)) trainset &lt;- iris[trainindex, ] testset &lt;- iris[-trainindex, ]  # fit a model to the training set (column 1, Sepal.Length, will be the outcome) set.seed(42) model &lt;- randomForest(x=trainset[ ,-1],y=trainset[ ,1])  # predict values for the testing set (the first column is the outcome, leave it out) predicted &lt;- predict(model, testset[ ,-1])  # what's the squared correlation coefficient between predicted and actual values? cor(predicted, testset[, 1])^2  # now, refit the model using built-in x.test and y.test set.seed(42) randomForest(x=trainset[ ,-1], y=trainset[ ,1], xtest=testset[ ,-1], ytest=testset[ ,1])
78130
How do you test for significant differences in skewness across two distributions of citation data, using R? I'm trying to compare the two power-law distributed histograms below (I'm just using histograms to visualize it, the data is not actually reduced to histograms). The sample sizes are 121 and 85 respectively. The skewness is very different (roughly 3 and 6 respectively), but how do I test if this difference is significant?
108714
I have a feeling this may have been asked elsewhere, but not really with the type of basic description I need.  I know non-parametric relies on the median instead of the mean to compare... something.  I also believe it relies on "degrees of freedom"(?) instead of standard deviation.  Correct me if I'm wrong, though.  I've done pretty good research, or so I'd thought, trying to understand the concept, what the workings are behind it, what the test results really mean, and/or what to even do with the test results; however, no one seems to ever venture into that area.  For the sake of simplicity let's stick with the Mann-Whitney U-test, which I've noticed is quite popular (and also seemingly misused and overused too in order to force one's "square model into a circle hole").  If you'd like to describe the other tests as well feel free, although I feel once I understand one, I can understand the others in an analogous way towards various t-tests etc.  Let's say I run a non-parametric test with my data and I get this result back:  2 Sample Mann-Whitney - Customer Type         Test Information         H0: Median Difference = 0        Ha: Median Difference ≠ 0         Size of Customer    Large   Small Count                    45    55 Median                    2     2  Mann-Whitney Statistic: 2162.00  p-value (2-sided, adjusted for ties):   0.4156     I'm familiar with other methods, but what is different here?  Should we want the p-value to be lower than .05?  What does the "Mann-Whitney statistic" mean?  Is there any use for it?  Does this information here just verify or not verify that a particular source of data I have should or should not be used?  I have a reasonable amount of experience with regression and the basics, but am very curious about this "special" non-parametric stuff - which I know will have it's own shortcomings.  Just imagine I'm a fifth grader and see if you can explain it to me.
101315
I am looking at using the lasso as a method for selecting features and fitting a predictive model with a binary target.  Below is some code I was playing with to try out the method with regularized logistic regression.  My question is I get a group of "significant" variables but am I able to rank order these to estimate relative importance of each? Can the coefficients be standardized for this purpose of rank by absolute value (I understand that they are shown on the original variable scale through the coef function)? If so, how to do so (using the standard deviation of x and y) .  SAMPLE CODE:      library(glmnet)      #data comes from  #http://archive.ics.uci.edu/ml/datasets/Breast+Cancer+Wisconsin+(Diagnostic)      datasetTest &lt;- read.csv('C:/Documents and Settings/E997608/Desktop/wdbc.data.txt',head=FALSE)   #appears to use the first level as the target success    datasetTest$V2&lt;-as.factor(ifelse(as.character(datasetTest$V2)=="M","0","1"))   #cross validation to find optimal lambda #using the lasso because alpha=1      cv.result&lt;-cv.glmnet(                      x=as.matrix(dataset[,3:ncol(datasetTest)]),               y=datasetTest[,2],                       family="binomial",                       nfolds=10,                       type.measure="deviance",                      alpha=1                     )  #values of lambda used      histogram(cv.result$lambda)  #plot of the error measure (here was deviance) #as a CI from each of the 10 folds #for each value of lambda (log actually)      plot(cv.result)   #the mean cross validation error (one for each of the #100 values of lambda      cv.result$cvm  #the value of lambda that minimzes the error measure #result: 0.001909601      cv.result$lambda.min     log(cv.result$lambda.min)  #the value of lambda that minimzes the error measure #within 1 SE of the minimum #result: 0.007024236      cv.result$lambda.1se  #the full sequence was fit in the object called cv.result$glmnet.fit #this is same as a call to it directly. #here are the coefficients from the min lambda      coef(cv.result$glmnet.fit,s=cv.result$lambda.1se)
71571
I'm pretty new to statistics and I need your help. I have a small sample, as follows:    H4U   0.269   0.357   0.2   0.221   0.275   0.277   0.253   0.127   0.246   I ran the Shapiro-Wilk test using R:    shapiro.test(precisionH4U$H4U)   and I got the following result:   W = 0.9502, p-value = 0.6921   Now, if I assume the significance level at 0.05 than the p-value is larger then alpha (0.6921 > 0.05) and I cannot reject the null hypothesis about the normal distribution, but does it allow me to say that the sample has a normal distribution?  Thanks!
120636
I seem to have confused myself trying to understand if a $r$-squared value also has a $p$-value.  As I understand it, in linear correlation with a set of data points $r$ can have a value ranging from $-1$ to $1$ and this value, whatever it is, can have a $p$-value which shows if $r$ is significantly different from $0$ (i.e., if there is a linear correlation between the two variables).  Moving on to linear regression, a function can be fitted to the data, described by the equation $Y = a + bX$. $a$ and $b$  (intercept and slope) also have $p$-values to show if they are significantly different from $0$.  Assuming I so far have understood everything correct, are the $p$-value for $r$ and the $p$-value for $b$ just the same thing? Is it then correct to say that it is not $r$-squared that has a $p$-value but rather $r$ or $b$ that does?
56977
I've recently been reading about the Mann-Whitney U test. It turns out that to carry out this test in R you actually need to run a Wilcoxon test!  My question: is the W statistic of wilcox.test in R identical to the U statistic?
115570
Question  The test scores of three groups of people are saved as separate vectors in R.  set.seed(1) group1 &lt;- rnorm(100, mean = 75, sd = 10) group2 &lt;- rnorm(100, mean = 85, sd = 10) group3 &lt;- rnorm(100, mean = 95, sd = 10)   I want to know if there is a significant difference in the medians between these groups. I know that I could test group 1 versus group 2 using the Wilcoxon test, like so.  wilcox.test(group1, group2)   However, this compares only two groups at a time, and I would like to compare all three simultaneously. I would like a statistical test that yields a p value at the 0.05 significance level. Could someone please help?  Edit #1 - Mood's median test  Following user Hibernating's suggested answer, I tried Mood's median test.  median.test &lt;- function(x, y){     z &lt;- c(x, y)     g &lt;- rep(1:2, c(length(x), length(y)))     m &lt;- median(z)     fisher.test(z &lt; m, g)$p.value }  median.test(group1, group2)   However, this approach allows me to test for a significant difference between the medians of only two groups at a time. I am not sure of how to use it to compare the medians of all three simultaneously.  Edit #2 - Kruskal-Wallis test  User dmartin's suggested answer appears to be more or less what I need, and allows me to test all three groups simultaneously.  kruskal.test(list(group1, group2, group3))   Edit #3  User Greg Snow helpfully notes in his answer that the Kruskal-Wallis test is appropriate as long as it makes strict assumptions that make it also a test of means.
8582
I have a question on how a statistician would normally interpret an anova output. Say I have anova output from R.  &gt; summary(fitted_data)  Call: lm(formula = V1 ~ V2)  Residuals:      Min       1Q   Median       3Q      Max  -2.74004 -0.33827  0.04062  0.44064  1.22737   Coefficients:             Estimate Std. Error t value Pr(&gt;|t|)     (Intercept)  2.11405    0.32089   6.588  1.3e-09 *** V2           0.03883    0.01277   3.040  0.00292 **  --- Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1   Residual standard error: 0.6231 on 118 degrees of freedom Multiple R-squared: 0.07262,    Adjusted R-squared: 0.06476  F-statistic:  9.24 on 1 and 118 DF,  p-value: 0.002917   &gt; anova(fit) Analysis of Variance Table  Response: V1            Df Sum Sq Mean Sq F value   Pr(&gt;F)    V2          1  3.588  3.5878  9.2402 0.002917 ** Residuals 118 45.818  0.3883                     --- Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1    From the above, I guess the most important value is Pr(>F), right? So this Pr, is less than 0.05 (95% level). How should my "explain" this? Do I explain it in "association", ie, V2 and V1 are associated (or not) ? or in terms of "significance"? I always felt that I couldn't understand when people say "This value is significant....". So what is "significant"? Is there a more intuitive form of explanation? like "I am 95% confident that ...." .   Also, is the Pr value the only important piece of information? or can i also look at residuals and the rest of the output to "explain" the result? thanks