# How to test hypothesis?

I have a table named app_satisfaction which has user_id, satisfaction, # of people they've invited.

I've grouped by satisfaction and found that on averge. people in satisfaction ="BAD" group invted 2.25 people, "GOOD" group invited 2.09 people, and "EXECELLENT" group invited 1.89 people.

So my hypothesis is people who dislike the app are more likely to invite people since inviting people gives them free coupon and they do not like to spend their own money on app they dislike.

I have a problem, just by looking at average invite in each group it seems unreasonable to draw conclusion. Also there are more people in "GOOD", "EXCELLENT" group compared to "BAD" group.

How can I test my hypothesis? what are the approaches one might take in real world problems?

As far as I understand, you have factors ("bad, "good" etc) and continuous "invitations". If you want to compare two groups you could use a t-test (e.g. Wilcoxon). If you want to compare all of the groups, you could use a simple linear regression of form:

$$invitations = \beta_0 satisfaction_1 + \beta_1 satisfaction_2 + ... + u.$$

R example:

library("e1071")
iris = iris

table(iris$$Species) #iris = iris[!(iris$$Species=="versicolor"),]

library(dplyr)

iris %>%
group_by(Species) %>%
summarise_at(vars(Sepal.Length), funs(mean(., na.rm=TRUE)))


Result (means):

# A tibble: 3 x 2
Species    Sepal.Length
<fct>             <dbl>
1 setosa             5.01
2 versicolor         5.94
3 virginica          6.59


Compare two groups:

# Two-samples Wilcoxon test
wilcox.test(iris$$Sepal.Length[iris$$Species=="setosa"], iris$$Sepal.Length[iris$$Species=="virginica"])
# The p-value is less than the significance level alpha = 0.05. We can conclude that Sepal Length is significantly different


Result:

    Wilcoxon rank sum test with continuity correction

data:  iris$$Sepal.Length[iris$$Species == "setosa"] and iris$$Sepal.Length[iris$$Species == "virginica"]
W = 38.5, p-value < 2.2e-16
alternative hypothesis: true location shift is not equal to 0


Regression:

# Simple linear regression
summary(lm(Sepal.Length~Species, data=iris))
# p-values are smaller than 0.05 which means each factor's contribution is statistically different from the intercept


Result:

Call:
lm(formula = Sepal.Length ~ Species, data = iris)

Residuals:
Min      1Q  Median      3Q     Max
-1.6880 -0.3285 -0.0060  0.3120  1.3120

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)         5.0060     0.0728  68.762  < 2e-16 ***
Speciesversicolor   0.9300     0.1030   9.033 8.77e-16 ***
Speciesvirginica    1.5820     0.1030  15.366  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.5148 on 147 degrees of freedom
Multiple R-squared:  0.6187,    Adjusted R-squared:  0.6135
F-statistic: 119.3 on 2 and 147 DF,  p-value: < 2.2e-16


The interesting bit here is Pr(>|t|). If the number in this column is smaller 0.05, you can say that the factor is significantly different from the intercept (which is the base category, in this case "setosa").

In this application, the column Estimate directly gives you the mean of "setosa" for the intercept. The effect for "versicolor" is 0.9300, where 5.0060+0.9300=5.936, which is the mean for "versicolor" and so on.