Assignment 3 - Part 2

Assignments
Author

Khushi

Introduction

We are investigating the influence of Dietary Preference and Gender on Tipping Behaviour.

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(mosaic)
Registered S3 method overwritten by 'mosaic':
  method                           from   
  fortify.SpatialPolygonsDataFrame ggplot2

The 'mosaic' package masks several functions from core packages in order to add 
additional features.  The original behavior of these functions should not be affected by this.

Attaching package: 'mosaic'

The following object is masked from 'package:Matrix':

    mean

The following objects are masked from 'package:dplyr':

    count, do, tally

The following object is masked from 'package:purrr':

    cross

The following object is masked from 'package:ggplot2':

    stat

The following objects are masked from 'package:stats':

    binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
    quantile, sd, t.test, var

The following objects are masked from 'package:base':

    max, mean, min, prod, range, sample, sum
library(ggformula)
library(crosstable)

Attaching package: 'crosstable'

The following object is masked from 'package:purrr':

    compact
library(skimr)

Attaching package: 'skimr'

The following object is masked from 'package:mosaic':

    n_missing
library(dplyr)
library(broom)

Research Experiment to Investigate the Influence of Dietary Preference and Gender on Tipping Behaviour

Objective:
The purpose of this research experiment is to investigate whether there is a significant difference in the amount of tips given by vegetarians and non-vegetarians. Additionally, the study aims to test whether one gender tends to tip more than the other. By collecting and analyzing tipping data, we aim to explore both dietary and gender-based differences in tipping behaviour.

Hypotheses:

  • Primary Hypothesis:
    Non-vegetarians tend to give higher tips on average compared to vegetarians.

  • Additional Hypothesis:
    One gender (e.g., males) tends to give higher tips on average compared to the other gender (e.g., females).

Experiment Design: Data Collection:

  • Sample: The dataset consists of tipping data from 60 students at MAHE Bengaluru. There are 30 males and 30 females, with each gender group containing 15 vegetarians and 15 non-vegetarians. The participants were randomly selected through coin tosses and asked to record the amount they tipped during a meal on October 24th, 2024.

  • Data Sources: The data was recorded in an Excel sheet by the people conducting the experiment. Each participant reported the tip amount they gave, along with their dietary preference (vegetarian or non-vegetarian) and gender.

Variables Measured:

  • Target Variable: The amount of tip given by each participant during the experiment period.

  • Predictor Variables:

    • Dietary Preference (Vegetarian vs. Non-Vegetarian)

    • Gender (Male vs. Female)

Sampling:

  • Time Period: The experiment was conducted on October 24th, 2024, over a period of 1.5 hours.

  • Participant Selection Criteria: 30 males and 30 females were randomly selected by tossing a coin. Within each gender group, 15 participants were vegetarians and 15 were non-vegetarians. Their dietary preferences and tipping behaviour were recorded accordingly.

Analysis Plan:

  • Data Cleaning and Transformation: The data was checked for accuracy in the Excel sheet, ensuring that each participant’s tipping amount, dietary preference, and gender were properly recorded, with no missing or erroneous entries.

  • Exploratory Data Analysis (EDA): Visualizations such as histograms, box plots, and scatter plots will be used to compare tipping distributions between vegetarians and non-vegetarians, as well as between males and females. This will help identify patterns or discrepancies in tipping behaviour.

Statistical Tests:

  • Two-Sample t-Test (Dietary Preference): A two-independent sample test for means will be conducted to compare the average tip amount given by vegetarians and non-vegetarians. This will help determine if there is a statistically significant difference in tipping behaviour between the two dietary groups.

  • Two-Sample t-Test (Gender): A separate two-sample t-test will be conducted to compare the average tip amount given by males and females. This will help determine if there is a statistically significant difference in tipping behaviour between the two genders.

  • Permutation Test (Dietary Preference & Gender): A permutation test will be conducted to assess the likelihood of the observed differences in tipping amounts (for both dietary preference and gender) occurring by chance, providing a non-parametric alternative to the two-sample t-tests.

  • Descriptive Statistics: Measures like mean, median, and standard deviation will be calculated for both groups (vegetarians vs. non-vegetarians and males vs. females) to summarize tipping behaviour.

  • Wilcoxon Rank-Sum Test: If the normality assumption is not met, a Wilcoxon rank-sum test (a non-parametric test) will be conducted to compare the tipping behaviour between vegetarians and non-vegetarians, as well as between males and females.

Limitations:

  • Sample Size: With 30 participants per group (15 vegetarians and 15 non-vegetarians for each gender), the results may not be generalizable to a larger population. A more extensive sample would provide greater reliability.

  • Contextual Factors: The study did not account for external factors that might influence tipping behaviour, such as the quality of service, the total bill amount, or personal tipping habits, which could have an effect on the tip amount.

Outcome:

The analysis will reveal whether significant differences in tipping behaviour exist between vegetarians and non-vegetarians and between males and females at MAHE Bengaluru. If the hypotheses hold, it would suggest that non-vegetarians, on average, tend to give higher tips than vegetarians, and one gender may tend to tip more than the other. These findings will provide insights into whether dietary preferences and gender influence tipping behaviour within this student population.

Dataset - Tipping

tip <- read_csv("../../data/tip.csv")
Rows: 60 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Name, Gender, Preference
dbl (1): Tip

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
tip
# A tibble: 60 × 4
   Name     Gender Preference   Tip
   <chr>    <chr>  <chr>      <dbl>
 1 Aanya    Female Veg            0
 2 Adit     Male   Veg            0
 3 Aditi    Female Veg           20
 4 Akash    Male   Non-veg        0
 5 Akshita  Female Non-veg        0
 6 Anandita Female Non-veg        0
 7 Ananya   Female Non-veg       20
 8 Anaya    Female Veg           35
 9 Anhuya   Female Veg           40
10 Ankit    Male   Non-veg        0
# ℹ 50 more rows

The dataset shown contains tipping data for 60 students at MAHE Bengaluru. The data includes four variables: Name, Gender, Dietary Preference (Vegetarian or Non-Vegetarian), and Tip Amount. Each row represents one participant’s recorded tip amount. The participants are evenly split between males and females, as well as between vegetarians and non-vegetarians. There are variations in tipping amounts, with some participants tipping as high as 40 units, while others tipped nothing.

tip_modified <- tip %>% 
  dplyr::mutate( Gender = as_factor(Gender))

Glimpse - Tipping

glimpse(tip_modified)
Rows: 60
Columns: 4
$ Name       <chr> "Aanya", "Adit", "Aditi", "Akash", "Akshita", "Anandita", "…
$ Gender     <fct> Female, Male, Female, Male, Female, Female, Female, Female,…
$ Preference <chr> "Veg", "Veg", "Veg", "Non-veg", "Non-veg", "Non-veg", "Non-…
$ Tip        <dbl> 0, 0, 20, 0, 0, 0, 20, 35, 40, 0, 0, 0, 0, 0, 0, 0, 20, 0, …

The Gender variable is stored as a factor, with participants divided evenly between males and females. The Tip amounts vary, with a range from 0 to 100 units. Some participants did not tip, while others left substantial tips, suggesting variability in tipping behaviour.

Inspect - Tipping

inspect(tip_modified)

categorical variables:  
        name     class levels  n missing
1       Name character     60 60       0
2     Gender    factor      2 60       0
3 Preference character      2 60       0
                                   distribution
1 Aanya (1.7%), Adit (1.7%) ...                
2 Female (50%), Male (50%)                     
3 Non-veg (50%), Veg (50%)                     

quantitative variables:  
  name   class min Q1 median Q3 max     mean       sd  n missing
1  Tip numeric   0  0      0 20 100 11.16667 17.83556 60       0

The tip amounts range from 0 to 100, with the median tip amount being 0, and the first and third quartiles (Q1 and Q3) being 0 and 20, respectively. The mean tip amount is approximately 11.1, with a standard deviation of 17.8.

Skim - Tipping

skim(tip_modified)
Data summary
Name tip_modified
Number of rows 60
Number of columns 4
_______________________
Column type frequency:
character 2
factor 1
numeric 1
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Name 0 1 4 9 0 60 0
Preference 0 1 3 7 0 2 0

Variable type: factor

skim_variable n_missing complete_rate ordered n_unique top_counts
Gender 0 1 FALSE 2 Fem: 30, Mal: 30

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Tip 0 1 11.17 17.84 0 0 0 20 100 ▇▁▁▁▁

The tips range from 0 to 100, with an average (mean) tip of approximately 11.17 rupees and a standard deviation of 17.84 rupees. Most participants did not give any tips, as indicated by the median and lower quartile values being 0. The data shows variability in tipping behaviour across individuals, with some participants giving significantly higher tips (as shown by the maximum value of 100).

Data Dictionary

Quantitative Data:

  • Tip (dbl): The total tip amount given by each participant, recorded in Indian rupees.

Qualitative Data:

  • Name (chr): The name of the participant.

  • Gender (fct): The gender of the participant, categorized as either Male or Female.

  • Preference (chr): The dietary preference of the participant, categorized as either Vegetarian (Veg) or Non-Vegetarian (Non-veg).

Histogram - Distribution of Tips by Dietary Preference

gf_histogram( ~ Tip | Preference, 
              data = tip_modified, 
              binwidth = 10, 
              fill = "skyblue", 
              color = "black" 
) %>%
gf_labs(
    title = "Distribution of Tips by Dietary Preference",
    x = "Tip Amount (in Rupees)",
    y = "Count"
)

The histogram visualizes the distribution of tips given by vegetarians and non-vegetarians. Both groups show a significant number of participants who gave no tips at all, with vegetarians showing a higher concentration of zero tips compared to non-vegetarians. Among those who did tip, non-vegetarians gave a larger number of tips in the range of ₹0 to ₹25, with fewer participants tipping above ₹50. In contrast, a few vegetarians tipped more substantial amounts, with one participant tipping ₹100, while most tips were clustered between ₹0 and ₹25. Overall, non-vegetarians tend to provide more tips within the lower ranges, while vegetarians exhibit a broader spread, with some giving higher tips. However, the majority of both groups tend to tip small amounts or none at all.

Histogram - Distribution of Tips by Gender

gf_histogram( ~ Tip | Gender, 
              data = tip_modified, 
              binwidth = 10, 
              fill = "lightgreen", 
              color = "black" 
) %>%
gf_labs(
    title = "Distribution of Tips by Gender",
    x = "Tip Amount (in Rupees)",
    y = "Count"
)

The histogram displays the distribution of tips given by gender. Both males and females show a significant number of participants who did not give any tips at all, with males having a slightly higher concentration of zero tips. Among those who did tip, most females provided tips in the ₹0 to ₹25 range, with a few tipping up to ₹50. In contrast, males also predominantly tipped in the ₹0 to ₹25 range, but there is a notable outlier where one male tipped ₹100, which is higher than any tip given by females. Overall, both genders tend to give small tips, though males show a broader range of tipping amounts, with the maximum tip coming from a male participant.

Box plot - Distribution of Tips by Dietary Preference

gf_boxplot(Tip ~ Preference,
  data = tip_modified,
  fill = ~Preference) %>%
  gf_labs(
    title = "Distribution of Tips by Dietary Preference",
    x = "Dietary Preference",
    y = "Tip Amount (in Rupees)"
  )

The box plot comparing the distribution of tips between vegetarians and non-vegetarians reveals that both groups have similar ranges of tip amounts, but there is an outlier in the vegetarian group with a higher tip of 100 rupees. The median tip for both vegetarians and non-vegetarians is around the same value. However, the spread (interquartile range) of tips is slightly broader for non-vegetarians. The presence of an outlier in the vegetarian group suggests that one individual tipped significantly more than the majority of participants in both groups, while most participants tipped relatively low amounts. Overall, the box plot indicates that tipping behaviour is fairly similar between the two dietary preference groups, with no major differences in the central tendency.

Box Plot - Distribution of Tips by Gender

gf_boxplot(Tip ~ Gender,
  data = tip_modified,
  fill = ~Gender) %>%
  gf_labs(
    title = "Distribution of Tips by Gender",
    x = "Gender",
    y = "Tip Amount (in Rupees)"
  )

The box plot comparing the distribution of tips between males and females shows that both genders have similar tipping patterns in terms of median and spread. The median tip amount is nearly the same for both groups, with the interquartile range (IQR) for females slightly broader than for males. However, there is an outlier in the male group, where one individual tipped a significantly higher amount (100 rupees) compared to the rest. Despite this outlier, the central tendency and overall distribution appear quite similar between males and females, suggesting no major gender-based differences in tipping behaviour.

Scatter Plot - Individual Tipping Behaviour by Gender and Dietary Preference

gf_point(Tip ~ Gender | Preference, 
         data = tip_modified,
         color = ~ Gender,
         shape = ~ Preference) %>%
  gf_labs(
    title = "Individual Tipping Behaviour by Gender and Dietary Preference",
    x = "Gender and Dietary Preference",
    y = "Tip Amount (in Rupees)"
  )

The scatter plot visually represents individual tipping behaviour, comparing tips based on both gender and dietary preference. In the plot, female and male participants are shown with different colours, while vegetarian and non-vegetarian participants are distinguished by different shapes. The data reveals that the majority of participants across all categories (female/male, veg/non-veg) tend to give lower tips (below 50 rupees), but there are a few outliers, especially in the vegetarian category, where some participants gave tips as high as 100 rupees. Non-vegetarians, on the other hand, generally tip in smaller amounts.

Density Plot

tip_modified %>%
  gf_density(~ Tip, fill = ~ Preference, alpha = 0.5) %>%
  gf_fitdistr(~ Tip, dist = "dnorm") %>%
  gf_labs(
    title = "Density Plot of Tip Amount by Dietary Preference",
    subtitle = "Compared with Normal Distribution",
    x = "Tip Amount (in Rupees)",
    y = "Density"
  )

tip_modified %>%
  gf_density(~ Tip, fill = ~ Gender, alpha = 0.5) %>%
  gf_fitdistr(~ Tip, dist = "dnorm") %>%
  gf_labs(
    title = "Density Plot of Tip Amount by Gender",
    subtitle = "Compared with Normal Distribution",
    x = "Tip Amount (in Rupees)",
    y = "Density"
  )

The density plots provide a visual comparison of the tipping behaviour across dietary preferences (vegetarians vs. non-vegetarians) and gender (males vs. females). In both cases, the tipping behaviour is skewed towards lower tip amounts, with the highest density of tips being in the range of 0 to 25 rupees. The comparison against the normal distribution suggests that the tip data does not follow a normal distribution, especially for the lower tip amounts.

For dietary preferences, non-vegetarians tend to tip slightly higher than vegetarians, as indicated by the density curve extending further towards higher tip amounts. However, the difference is not substantial, and both groups show a similar overall distribution of low tips.

In terms of gender, the male participants appear to give slightly higher tips compared to female participants, as seen by the male density curve being more spread towards the higher tip amounts. Nonetheless, both genders also demonstrate a strong tendency towards giving lower tips, with a majority of tips clustered in the lower ranges. Overall, while there are slight differences, tipping behaviour across both dietary preference and gender is heavily skewed towards lower amounts.

Crosstable

crosstable(
  tip_modified, 
  c(Gender, Preference), 
  showNA = "ifany"
) %>%
  crosstable::as_flextable()

label

variable

value

Gender

Female

30 (50.00%)

Male

30 (50.00%)

Preference

Non-veg

30 (50.00%)

Veg

30 (50.00%)

tip_modified %>%
  group_by(Gender, Preference) %>%
  summarize(
    Mean_Tip = mean(Tip, na.rm = TRUE),
    Median_Tip = median(Tip, na.rm = TRUE),
    Count = n()
  )
`summarise()` has grouped output by 'Gender'. You can override using the
`.groups` argument.
# A tibble: 4 × 5
# Groups:   Gender [2]
  Gender Preference Mean_Tip Median_Tip Count
  <fct>  <chr>         <dbl>      <dbl> <int>
1 Female Non-veg       11.3           0    15
2 Female Veg           13             0    15
3 Male   Non-veg        8.67          0    15
4 Male   Veg           11.7           0    15

The cross table shows that the tipping dataset contains an equal number of males and females, with 30 participants in each group. Similarly, there are equal numbers of participants with dietary preferences, 30 for vegetarians and 30 for non-vegetarians. When breaking down by gender and dietary preference, the average tip given by females who are non-vegetarians is ₹11.33, while females who are vegetarians tip an average of ₹13. For males, non-vegetarians give an average of ₹8.67, while vegetarians tip an average of ₹11.67. The median tip for all groups remains ₹0, indicating that many participants may not have tipped, skewing the distribution. These results suggest some differences in tipping behaviour based on dietary preferences and gender, though the prevalence of non-tipping behaviour is noticeable across all groups.

T-test for Vegetarians vs. Non-Vegetarians

t_test_veg_nonveg <- t.test(
  Tip ~ Preference,
  data = tip_modified,
  var.equal = FALSE 
) %>% 
broom::tidy()

t_test_veg_nonveg
# A tibble: 1 × 10
  estimate estimate1 estimate2 statistic p.value parameter conf.low conf.high
     <dbl>     <dbl>     <dbl>     <dbl>   <dbl>     <dbl>    <dbl>     <dbl>
1    -2.33        10      12.3    -0.503   0.617      46.9    -11.7      6.99
# ℹ 2 more variables: method <chr>, alternative <chr>

The t-test conducted to compare the average tip amounts between vegetarians and non-vegetarians shows a p-value of 0.617. This high p-value indicates that there is no statistically significant difference between the two groups. The estimated mean tip for vegetarians is ₹12.33, while for non-vegetarians, it is ₹10, resulting in a mean difference of approximately ₹2.33. The 95% confidence interval for this difference is from -11.66 to 6.99, which includes zero, further suggesting that there is no significant difference in tipping behaviour based on dietary preference. Therefore, the data does not support the hypothesis that non-vegetarians tip more than vegetarians.

T-test for Males vs. Females

t_test_gender <- t.test(
  Tip ~ Gender,
  data = tip_modified,
  var.equal = FALSE 
) %>% 
broom::tidy()

t_test_gender
# A tibble: 1 × 10
  estimate estimate1 estimate2 statistic p.value parameter conf.low conf.high
     <dbl>     <dbl>     <dbl>     <dbl>   <dbl>     <dbl>    <dbl>     <dbl>
1        2      12.2      10.2     0.431   0.668      55.8    -7.29      11.3
# ℹ 2 more variables: method <chr>, alternative <chr>

The t-test comparing the average tip amounts between males and females reveals no significant difference in tipping behaviour. The mean tip for males was ₹10.17, and for females, it was ₹12.17. The test produced a t-statistic of 0.431 and a p-value of 0.668, which is much higher than the standard significance level of 0.05. Additionally, the 95% confidence interval ranges from -7.29 to 11.29, suggesting that the true difference in means could be anywhere within this range, including zero.

Wilcoxon Rank-Sum Test for Vegetarians vs. Non-Vegetarians

wilcox_test_veg_nonveg <- wilcox.test(
  Tip ~ Preference,
  data = tip_modified,
  alternative = "two.sided",
  conf.int = TRUE
) %>%
  broom::tidy()
Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
compute exact p-value with ties
Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
compute exact confidence intervals with ties
wilcox_test_veg_nonveg
# A tibble: 1 × 7
   estimate statistic p.value   conf.low   conf.high method          alternative
      <dbl>     <dbl>   <dbl>      <dbl>       <dbl> <chr>           <chr>      
1 0.0000372       463   0.833 -0.0000335 0.000000989 Wilcoxon rank … two.sided  

The Wilcoxon Rank-Sum Test conducted to compare the tipping behaviour between vegetarians and non-vegetarians resulted in a p-value of 0.83. This high p-value suggests that there is no statistically significant difference in the tipping amounts between the two groups. The confidence interval also crosses zero, reinforcing the conclusion that the median tip amounts for vegetarians and non-vegetarians are not significantly different. This non-parametric test confirms that dietary preference does not appear to influence tipping behaviour within this dataset.

Wilcoxon Rank-Sum Test for Males vs. Females

wilcox_test_gender <- wilcox.test(
  Tip ~ Gender,
  data = tip_modified,
  alternative = "two.sided",
  conf.int = TRUE
) %>%
  broom::tidy()
Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
compute exact p-value with ties
Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
compute exact confidence intervals with ties
wilcox_test_gender
# A tibble: 1 × 7
   estimate statistic p.value   conf.low  conf.high method           alternative
      <dbl>     <dbl>   <dbl>      <dbl>      <dbl> <chr>            <chr>      
1 0.0000445       498   0.422 -0.0000134 0.00000497 Wilcoxon rank s… two.sided  

The results of the Wilcoxon Rank-Sum Test comparing tipping behaviour between males and females show no significant difference in tipping amounts between the two genders. The p-value is 0.42, which is much higher than the conventional threshold of 0.05, indicating that any observed differences in tipping amounts between males and females are not statistically significant. Both the confidence interval values are very close to zero, further supporting the conclusion that there is no significant difference between male and female tipping behaviour. Thus, tipping behaviour seems similar across both genders in this dataset.

Permutation Test for Vegetarians vs Non-Vegetarians

perm_test_veg_nonveg <- do(1000) * diffmean(Tip ~ shuffle(Preference), data = tip_modified)
perm_test_veg_nonveg
        diffmean
1     -3.6666667
2      4.6666667
3      3.0000000
4      1.6666667
5      1.3333333
6      3.6666667
7      1.6666667
8     -3.0000000
9      2.0000000
10     0.6666667
11     4.0000000
12    -4.6666667
13    -3.3333333
14     3.6666667
15     0.6666667
16     5.3333333
17   -10.0000000
18    -1.3333333
19    -0.6666667
20    -2.0000000
21    -0.3333333
22     2.0000000
23     3.6666667
24    -3.0000000
25     1.6666667
26    -9.0000000
27     0.6666667
28     0.3333333
29    -2.6666667
30     5.3333333
31    -5.6666667
32     6.0000000
33    -7.6666667
34     1.3333333
35     0.3333333
36    -5.0000000
37    -1.3333333
38    -3.0000000
39     0.3333333
40     6.3333333
41    -5.0000000
42     2.6666667
43     7.3333333
44    -3.0000000
45     6.0000000
46     3.6666667
47     1.6666667
48     3.0000000
49    -2.3333333
50    -1.0000000
51    -8.3333333
52    -0.3333333
53     7.6666667
54     1.6666667
55    -4.3333333
56    -7.6666667
57     5.6666667
58     1.0000000
59     2.0000000
60    -4.3333333
61    -3.3333333
62    -5.6666667
63    -1.6666667
64    -1.3333333
65    -2.0000000
66     2.6666667
67     7.0000000
68    -0.6666667
69    -3.6666667
70    -3.0000000
71    -6.3333333
72    -5.3333333
73    -1.6666667
74     4.0000000
75    -1.6666667
76     4.0000000
77    -1.3333333
78     4.0000000
79    -4.3333333
80     2.0000000
81    -4.6666667
82    -2.6666667
83     8.6666667
84    10.0000000
85     3.6666667
86     5.6666667
87     1.0000000
88     9.6666667
89     7.3333333
90    -5.6666667
91     3.3333333
92     2.0000000
93     4.0000000
94     1.3333333
95    -7.3333333
96   -11.0000000
97     2.6666667
98     0.0000000
99     0.3333333
100   -9.6666667
101   -2.3333333
102   -5.0000000
103   -1.3333333
104   -6.0000000
105   -2.3333333
106    5.6666667
107    8.6666667
108   -1.6666667
109    3.0000000
110   -1.6666667
111    0.6666667
112   -2.0000000
113    3.6666667
114   -8.6666667
115    0.6666667
116   -1.0000000
117    3.0000000
118    8.3333333
119    3.3333333
120    3.6666667
121   -4.0000000
122   -7.0000000
123    3.0000000
124    3.0000000
125    1.6666667
126    2.0000000
127   -4.0000000
128   -2.6666667
129    4.6666667
130    3.6666667
131    4.3333333
132   -6.6666667
133   -3.0000000
134   -1.3333333
135   -6.6666667
136   -6.6666667
137   -5.3333333
138    5.6666667
139   -1.0000000
140    2.3333333
141  -12.3333333
142   -8.0000000
143    2.3333333
144    0.3333333
145    3.0000000
146    2.6666667
147    6.3333333
148   -3.3333333
149   -0.3333333
150   -2.0000000
151    7.6666667
152    3.0000000
153    0.6666667
154    2.0000000
155   -1.3333333
156    3.0000000
157    2.3333333
158   -5.3333333
159    5.0000000
160    1.6666667
161    4.3333333
162   -4.0000000
163    0.3333333
164   -5.3333333
165    0.3333333
166    0.3333333
167   -1.3333333
168    5.6666667
169    0.3333333
170   -5.0000000
171   -4.3333333
172    0.6666667
173    5.6666667
174   -1.6666667
175    1.0000000
176    7.3333333
177   -6.6666667
178    1.3333333
179    5.3333333
180    1.6666667
181    6.3333333
182    5.3333333
183    2.0000000
184   -5.0000000
185   -8.0000000
186    3.0000000
187   -6.6666667
188    0.6666667
189   -1.6666667
190   -6.6666667
191   -7.3333333
192    5.6666667
193   -5.3333333
194   -4.6666667
195   -4.0000000
196    5.3333333
197   -4.0000000
198   -3.6666667
199    3.0000000
200    0.3333333
201   -6.0000000
202    2.0000000
203    8.6666667
204    0.0000000
205    0.3333333
206   -1.6666667
207    1.6666667
208   -3.0000000
209   -3.6666667
210   -3.6666667
211    5.3333333
212    4.0000000
213   -0.3333333
214    2.3333333
215   -4.3333333
216   -0.3333333
217    3.0000000
218   -7.6666667
219    4.0000000
220   -2.3333333
221   -4.3333333
222   -4.3333333
223   -9.6666667
224   -3.3333333
225    0.3333333
226    8.0000000
227    2.3333333
228   -2.0000000
229    3.3333333
230    2.6666667
231   -1.6666667
232   -3.6666667
233    7.0000000
234   -2.3333333
235    1.3333333
236   -2.3333333
237    3.6666667
238    5.3333333
239   -2.6666667
240    0.3333333
241    0.0000000
242    5.0000000
243    4.6666667
244    3.3333333
245    1.6666667
246    0.3333333
247    3.3333333
248   -1.3333333
249  -10.3333333
250    4.3333333
251    0.0000000
252   -6.0000000
253    5.6666667
254   -5.6666667
255   -0.3333333
256    6.3333333
257   -0.6666667
258    0.6666667
259   -0.3333333
260    4.0000000
261    5.6666667
262    3.3333333
263   -0.6666667
264    4.6666667
265   -2.6666667
266   -2.0000000
267   -3.6666667
268   -3.0000000
269   -2.0000000
270    1.0000000
271    0.3333333
272    2.0000000
273   -2.0000000
274   -0.6666667
275    5.6666667
276    1.3333333
277    2.0000000
278    6.6666667
279   -5.0000000
280   -0.6666667
281   -4.6666667
282   -4.6666667
283   -0.6666667
284    5.6666667
285   -5.0000000
286   -6.0000000
287    0.6666667
288    5.6666667
289    5.3333333
290    2.3333333
291   -2.6666667
292    9.3333333
293   -1.3333333
294    1.0000000
295    2.0000000
296   -3.0000000
297   -1.6666667
298    3.6666667
299   -9.0000000
300   10.3333333
301   -5.3333333
302   -0.6666667
303   -0.3333333
304   -5.0000000
305   -8.6666667
306    6.0000000
307    6.0000000
308    6.6666667
309    3.6666667
310    0.0000000
311    2.6666667
312    6.6666667
313    0.3333333
314    7.3333333
315    2.3333333
316    2.6666667
317   -3.0000000
318    4.0000000
319   -2.6666667
320   -5.3333333
321   -3.0000000
322    4.0000000
323    2.0000000
324    3.6666667
325   -3.3333333
326    3.3333333
327   10.0000000
328   -5.3333333
329    1.0000000
330    2.0000000
331    6.6666667
332    6.0000000
333   -7.0000000
334    5.3333333
335    1.0000000
336  -10.6666667
337   -1.0000000
338    7.3333333
339    0.3333333
340   -1.3333333
341    2.0000000
342    9.3333333
343   -6.6666667
344   -1.6666667
345    3.3333333
346    3.0000000
347    1.0000000
348    5.3333333
349    8.6666667
350   -1.3333333
351   -5.3333333
352    1.3333333
353    7.3333333
354   -1.0000000
355   -4.0000000
356    0.3333333
357   -3.3333333
358    0.6666667
359   -3.6666667
360   -1.0000000
361    1.3333333
362    0.0000000
363    2.0000000
364   -3.6666667
365    0.0000000
366   -2.0000000
367    5.0000000
368   -5.0000000
369   -5.3333333
370  -10.0000000
371    3.0000000
372    1.3333333
373   -9.3333333
374   -2.3333333
375   -7.6666667
376    4.6666667
377    2.0000000
378   10.0000000
379    0.3333333
380    4.3333333
381   -1.3333333
382    4.3333333
383    1.0000000
384   -6.3333333
385   -4.0000000
386    8.3333333
387    5.6666667
388    8.6666667
389    8.0000000
390    5.6666667
391    2.0000000
392   -4.0000000
393    1.6666667
394    2.3333333
395    5.0000000
396    5.3333333
397   -6.6666667
398    3.0000000
399    4.3333333
400    0.6666667
401  -13.3333333
402    5.6666667
403   -1.6666667
404   -2.3333333
405    7.3333333
406    2.0000000
407    6.3333333
408   -0.6666667
409    3.3333333
410   -0.6666667
411   -4.3333333
412    0.3333333
413   -6.6666667
414   -3.6666667
415   -5.0000000
416   -9.6666667
417    3.0000000
418    0.6666667
419   -1.3333333
420   -5.6666667
421    1.6666667
422   -0.3333333
423  -11.3333333
424   -1.0000000
425    1.0000000
426    3.0000000
427    0.6666667
428    4.6666667
429    1.0000000
430   -2.0000000
431  -11.0000000
432    1.3333333
433    2.0000000
434    1.0000000
435   -4.0000000
436   -6.0000000
437    0.6666667
438   -2.3333333
439   -7.3333333
440   -1.6666667
441    3.3333333
442   -3.6666667
443   -5.6666667
444    7.3333333
445    2.6666667
446    6.3333333
447    2.3333333
448   -4.6666667
449   -2.0000000
450   -0.3333333
451    0.3333333
452    0.0000000
453   -5.0000000
454   -1.6666667
455   -5.0000000
456   -1.0000000
457   -0.6666667
458   -2.0000000
459   -4.6666667
460   -2.6666667
461   -2.0000000
462   -8.0000000
463    1.6666667
464   -1.6666667
465    1.6666667
466   -8.0000000
467    0.6666667
468   -8.0000000
469    1.6666667
470    1.6666667
471   -4.3333333
472   -5.6666667
473   -3.3333333
474   -7.0000000
475   -0.6666667
476    4.3333333
477    3.6666667
478   -4.0000000
479    6.6666667
480    3.0000000
481    5.3333333
482   -4.0000000
483   -0.6666667
484    8.0000000
485    1.0000000
486   -5.3333333
487   -1.6666667
488   -2.3333333
489   -1.6666667
490   -3.0000000
491   -2.0000000
492   -7.6666667
493   -5.3333333
494    3.3333333
495    2.0000000
496    6.0000000
497   -1.3333333
498   -0.6666667
499   -8.0000000
500    7.0000000
501   -0.6666667
502    2.3333333
503    8.0000000
504    2.0000000
505   10.0000000
506   -3.0000000
507    1.0000000
508    6.6666667
509    0.3333333
510   -6.0000000
511   -3.0000000
512   -1.0000000
513    5.3333333
514   -3.0000000
515    2.0000000
516   -2.6666667
517    5.0000000
518   11.3333333
519    5.0000000
520    1.0000000
521   -3.0000000
522    4.6666667
523    0.0000000
524   -3.0000000
525    0.0000000
526    1.3333333
527   -4.0000000
528    0.3333333
529   -1.3333333
530   -4.6666667
531   -1.0000000
532    5.3333333
533    8.0000000
534    7.0000000
535   -3.6666667
536   -6.0000000
537   -1.6666667
538    8.0000000
539    5.3333333
540   -4.0000000
541    0.0000000
542   -1.3333333
543   -5.3333333
544   -1.6666667
545    0.3333333
546   -4.0000000
547   -4.6666667
548    4.3333333
549   -0.3333333
550    0.6666667
551   -2.6666667
552    2.0000000
553    4.0000000
554   -1.0000000
555    6.3333333
556   -1.0000000
557   -0.6666667
558   -4.0000000
559   -6.6666667
560   -4.0000000
561    5.3333333
562   -3.3333333
563    3.6666667
564    3.3333333
565    0.6666667
566   -6.0000000
567   -4.0000000
568   -4.0000000
569    1.0000000
570   -4.6666667
571   -2.3333333
572    1.6666667
573   -1.6666667
574    1.6666667
575   -6.6666667
576    0.3333333
577    5.3333333
578   -5.3333333
579   -1.6666667
580    6.6666667
581    5.3333333
582   -8.0000000
583    1.6666667
584   -5.3333333
585   -4.6666667
586   -2.0000000
587    7.0000000
588    4.0000000
589   -1.3333333
590   -5.0000000
591   -1.6666667
592    0.3333333
593   -4.6666667
594   -2.6666667
595   -1.3333333
596   -6.3333333
597   -8.0000000
598   -5.0000000
599   -3.0000000
600   -5.3333333
601    8.6666667
602   -3.6666667
603    6.6666667
604    1.3333333
605    4.3333333
606   -1.3333333
607   -0.3333333
608   -0.6666667
609    3.6666667
610    9.3333333
611    1.6666667
612   -2.6666667
613    9.3333333
614    3.6666667
615    0.6666667
616   -1.0000000
617   -7.0000000
618    1.3333333
619   -5.6666667
620   -6.0000000
621    7.6666667
622   -1.3333333
623   -5.3333333
624    5.3333333
625    2.6666667
626    1.3333333
627    1.6666667
628    2.6666667
629   -6.6666667
630   -0.6666667
631   -0.6666667
632   -6.6666667
633    6.3333333
634   -0.3333333
635    0.0000000
636    2.0000000
637    2.0000000
638   -7.6666667
639    7.6666667
640    4.0000000
641    6.6666667
642    6.3333333
643   -4.0000000
644    4.0000000
645    2.6666667
646   -2.0000000
647   -0.3333333
648    0.0000000
649   -1.6666667
650   -2.6666667
651    0.6666667
652    4.6666667
653    5.6666667
654   -5.3333333
655   -2.6666667
656   -1.0000000
657    1.6666667
658   -1.6666667
659    3.0000000
660    0.3333333
661   -2.3333333
662    6.0000000
663    2.3333333
664    5.3333333
665   -8.3333333
666    0.0000000
667   -6.3333333
668   -7.6666667
669   -6.3333333
670    2.6666667
671   -5.6666667
672   -4.3333333
673   -3.3333333
674   -7.0000000
675   -1.0000000
676   -8.0000000
677    1.3333333
678    2.0000000
679    0.0000000
680    1.6666667
681    1.3333333
682   -4.6666667
683    5.3333333
684   -5.3333333
685   -5.0000000
686    0.0000000
687   -8.6666667
688    1.0000000
689    3.0000000
690    6.6666667
691    6.6666667
692    3.6666667
693    4.6666667
694   -2.6666667
695   -0.3333333
696    1.0000000
697    2.3333333
698    5.3333333
699    0.0000000
700   -0.3333333
701    8.6666667
702    1.6666667
703    9.3333333
704    1.6666667
705   -5.3333333
706   -7.6666667
707   -2.3333333
708    1.0000000
709    2.6666667
710    6.6666667
711    1.0000000
712   -1.3333333
713    8.6666667
714   -3.6666667
715   -1.0000000
716   -2.6666667
717    0.0000000
718    0.0000000
719    3.6666667
720    0.0000000
721   -4.6666667
722   -1.0000000
723   -1.3333333
724    4.3333333
725   -4.6666667
726    6.6666667
727   -1.0000000
728    3.3333333
729    0.6666667
730   -3.0000000
731    0.3333333
732    6.0000000
733    4.6666667
734   -2.6666667
735    1.3333333
736   -7.3333333
737    0.0000000
738    3.0000000
739   -6.0000000
740    0.0000000
741   -3.0000000
742   -1.6666667
743    0.0000000
744   -1.0000000
745   -0.3333333
746   -5.6666667
747    0.6666667
748   -4.6666667
749   -5.6666667
750    4.0000000
751    3.0000000
752    2.6666667
753    1.3333333
754   -7.0000000
755   -3.3333333
756    2.3333333
757    8.3333333
758   -2.3333333
759    7.3333333
760   -2.6666667
761    8.0000000
762    4.6666667
763    5.3333333
764   -3.0000000
765    6.6666667
766   -0.6666667
767    0.0000000
768    4.3333333
769    1.0000000
770   -2.6666667
771   -1.3333333
772   -1.0000000
773   -2.0000000
774   -7.0000000
775    5.0000000
776    2.6666667
777   -1.6666667
778   -5.3333333
779   -2.3333333
780    3.0000000
781   -1.6666667
782    1.6666667
783    1.6666667
784    4.3333333
785    6.0000000
786    7.0000000
787    8.0000000
788   -3.6666667
789    8.0000000
790   -3.0000000
791    6.0000000
792   -1.6666667
793   -3.3333333
794   -2.3333333
795    9.6666667
796   -8.6666667
797   -4.0000000
798  -11.6666667
799    3.6666667
800   -2.6666667
801    3.0000000
802   -3.3333333
803    5.0000000
804    7.0000000
805    0.6666667
806   -8.6666667
807   10.6666667
808   -1.6666667
809    4.0000000
810   -1.3333333
811   -6.0000000
812    5.0000000
813    2.6666667
814    1.3333333
815    0.0000000
816   -5.0000000
817    8.0000000
818    1.6666667
819    3.6666667
820    5.6666667
821   -1.6666667
822   -1.6666667
823    7.0000000
824   -3.3333333
825   -5.6666667
826    4.0000000
827    2.3333333
828   -0.6666667
829   -3.0000000
830    2.3333333
831   -3.0000000
832    2.6666667
833    2.3333333
834   -9.6666667
835   -3.3333333
836    1.3333333
837    7.0000000
838   -3.0000000
839    5.6666667
840   -3.0000000
841   -5.6666667
842    1.3333333
843    5.3333333
844   -2.6666667
845   -2.0000000
846    0.6666667
847    3.3333333
848   -0.3333333
849    5.0000000
850   -3.3333333
851   -1.3333333
852    6.0000000
853   -5.3333333
854   -6.0000000
855   -7.3333333
856   -4.6666667
857    2.0000000
858   -5.0000000
859    5.6666667
860    6.6666667
861    0.0000000
862    1.6666667
863    8.3333333
864   -5.0000000
865    6.3333333
866   -1.0000000
867    7.0000000
868   -6.3333333
869    3.0000000
870   -5.3333333
871    5.6666667
872   -0.6666667
873    7.3333333
874    0.3333333
875   -7.6666667
876    3.6666667
877    2.0000000
878   -4.0000000
879    9.0000000
880   -1.3333333
881    2.6666667
882   -5.6666667
883   -3.6666667
884    5.6666667
885    4.0000000
886   -4.3333333
887    6.0000000
888    6.3333333
889   -5.3333333
890   -2.0000000
891    0.6666667
892    3.3333333
893   -3.0000000
894    1.3333333
895    1.0000000
896   -4.3333333
897   11.3333333
898   -4.3333333
899   -1.0000000
900    0.0000000
901    2.0000000
902    1.0000000
903  -10.3333333
904    1.6666667
905    1.6666667
906    4.6666667
907  -13.0000000
908   -1.6666667
909    1.3333333
910   -2.0000000
911    2.0000000
912   -5.6666667
913    2.0000000
914   -3.0000000
915   -6.0000000
916   -8.6666667
917    1.6666667
918   -4.6666667
919   -2.3333333
920   -0.6666667
921  -10.0000000
922    2.0000000
923    4.6666667
924    2.0000000
925   -2.0000000
926   -6.0000000
927    1.3333333
928   -6.3333333
929  -10.0000000
930   -3.6666667
931   -0.3333333
932   -7.3333333
933    4.6666667
934    0.6666667
935   -5.0000000
936   -4.0000000
937    0.3333333
938    4.0000000
939   -5.0000000
940    2.6666667
941   -3.0000000
942    9.0000000
943   -3.6666667
944   -5.3333333
945    3.0000000
946   -1.3333333
947    8.3333333
948    3.0000000
949    5.3333333
950   -2.6666667
951   -5.6666667
952   -5.3333333
953   -0.3333333
954    2.0000000
955    1.3333333
956   -2.3333333
957    3.6666667
958    6.6666667
959   -2.6666667
960    0.3333333
961   -4.6666667
962    0.0000000
963   -8.6666667
964   -5.0000000
965   -2.6666667
966   -1.6666667
967   -1.6666667
968   -7.6666667
969   -3.3333333
970   -1.3333333
971   -3.0000000
972    1.0000000
973   -2.0000000
974   -2.3333333
975    2.3333333
976   -8.0000000
977   -0.6666667
978    9.0000000
979    0.6666667
980    2.0000000
981    2.6666667
982    0.6666667
983    0.3333333
984    0.3333333
985    1.6666667
986    1.0000000
987    1.0000000
988    0.0000000
989   -3.6666667
990   -0.6666667
991    5.3333333
992   -1.3333333
993   -6.6666667
994    2.6666667
995    0.0000000
996   -5.3333333
997   -6.0000000
998   -2.0000000
999    6.6666667
1000   1.6666667

The permutation test for comparing tipping behaviour between vegetarians and non-vegetarians was conducted with 1000 iterations. The distribution of the difference in mean tips (diffmean) under the null hypothesis, where dietary preferences are randomly shuffled, suggests that the observed differences are small. The diffmean values range from negative to positive, indicating that differences in mean tip amounts vary slightly between vegetarians and non-vegetarians in the randomized samples. These differences appear to center around 0, with most of the values being close to it, implying that the observed differences between the two groups might not be statistically significant, and any difference in tipping behaviour could largely be due to chance.

Plotting the results of the Permutation Test

gf_histogram(~ diffmean, data = perm_test_veg_nonveg, bins = 30) %>%
  gf_labs(
    title = "Permutation Test for Tipping Differences: Vegetarians vs. Non-Vegetarians",
    x = "Difference in Mean Tip Amount",
    y = "Count"
  )

The histogram from the permutation test comparing tipping differences between vegetarians and non-vegetarians shows that the distribution of differences in mean tip amounts is approximately centered around zero. This suggests that, under random shuffling of dietary preferences, the observed differences in mean tips could occur by chance.

Observed difference for Vegetarians vs Non-Vegetarians

observed_diff_veg_nonveg <- diffmean(Tip ~ Preference, data = tip_modified)
observed_diff_veg_nonveg
diffmean 
2.333333 

The observed difference in the mean tip amount between vegetarians and non-vegetarians is approximately 2.33 rupees, with non-vegetarians giving a slightly higher average tip compared to vegetarians.

Calculating the p-value

p_value_veg_nonveg <- prop(~ (abs(diffmean) >= abs(observed_diff_veg_nonveg)), data = perm_test_veg_nonveg)
p_value_veg_nonveg
prop_TRUE 
    0.634 

The p-value calculated for the permutation test comparing the tipping behavior between vegetarians and non-vegetarians is 0.675. This high p-value suggests that there is no statistically significant difference in the mean tip amounts between the two dietary preference groups. The observed difference of 2.33 rupees could have likely occurred by random chance, indicating that the dietary preference (vegetarian vs. non-vegetarian) does not have a strong influence on tipping behaviour in this sample. Therefore, we fail to reject the null hypothesis.

Permutation test for Males vs Females

perm_test_gender <- do(1000) * diffmean(Tip ~ shuffle(Gender), data = tip_modified)
perm_test_gender
        diffmean
1      0.0000000
2      4.0000000
3     -2.6666667
4      5.3333333
5      6.6666667
6     -4.6666667
7      4.3333333
8      4.3333333
9     -5.3333333
10     0.0000000
11     0.6666667
12    -1.3333333
13     2.3333333
14    -5.3333333
15     3.3333333
16    -2.3333333
17   -10.3333333
18    -4.0000000
19    -3.3333333
20    -0.6666667
21     0.0000000
22     0.3333333
23     1.6666667
24    -2.0000000
25    -8.0000000
26    -5.0000000
27    -3.0000000
28    -2.6666667
29    -2.3333333
30     0.6666667
31    -6.0000000
32    -1.0000000
33    -1.6666667
34    -2.3333333
35    -6.0000000
36    -1.6666667
37     8.0000000
38     0.6666667
39     6.3333333
40    -9.3333333
41    -4.6666667
42    -1.6666667
43     1.3333333
44     8.3333333
45     0.3333333
46     5.6666667
47     1.6666667
48     7.6666667
49    -0.6666667
50    -1.6666667
51     4.6666667
52    -6.3333333
53    -0.3333333
54   -11.6666667
55     2.0000000
56     2.6666667
57     8.3333333
58     2.3333333
59    -4.0000000
60    -5.0000000
61     0.6666667
62    -9.6666667
63     3.3333333
64    -1.0000000
65     3.3333333
66    -1.6666667
67     0.3333333
68     1.0000000
69    -0.6666667
70     6.0000000
71    -1.6666667
72    -2.6666667
73     2.0000000
74    -6.3333333
75   -11.3333333
76    -3.3333333
77    -2.3333333
78    -3.0000000
79    -0.3333333
80    -3.3333333
81     2.6666667
82    -5.3333333
83    -4.6666667
84    -1.3333333
85     2.0000000
86    -2.6666667
87     1.3333333
88    -2.3333333
89    -3.3333333
90     2.6666667
91    -1.3333333
92    -7.0000000
93     4.6666667
94    -3.0000000
95    -7.3333333
96    -8.0000000
97    -6.0000000
98    -8.3333333
99     0.3333333
100    1.3333333
101    1.3333333
102    1.0000000
103   -2.6666667
104   -4.6666667
105   -1.6666667
106    1.0000000
107    1.6666667
108    1.3333333
109    5.3333333
110   -6.3333333
111    3.0000000
112    0.3333333
113   -3.6666667
114    1.0000000
115   -0.6666667
116   -1.3333333
117    5.3333333
118    0.3333333
119   -4.0000000
120   -3.0000000
121    0.0000000
122    4.6666667
123    1.6666667
124   -8.0000000
125    9.0000000
126   -4.3333333
127   -4.3333333
128    1.0000000
129    6.3333333
130    1.6666667
131    0.3333333
132   -1.3333333
133    0.3333333
134   -6.0000000
135   -1.3333333
136   -0.6666667
137    3.0000000
138   -2.0000000
139   -1.0000000
140    4.6666667
141    6.6666667
142  -10.0000000
143    4.3333333
144    2.3333333
145    2.0000000
146  -11.0000000
147   -4.3333333
148    0.3333333
149   -2.3333333
150   -2.3333333
151   -4.6666667
152    2.6666667
153    3.3333333
154   -3.0000000
155    1.3333333
156    4.3333333
157    1.0000000
158   -3.3333333
159   -2.0000000
160    4.3333333
161    5.6666667
162    4.3333333
163   -6.3333333
164    2.0000000
165   -2.6666667
166    0.0000000
167   -3.3333333
168   -2.3333333
169    0.3333333
170    8.0000000
171   -2.3333333
172    2.6666667
173   -3.6666667
174   -2.0000000
175    1.6666667
176   -0.3333333
177   -2.0000000
178    4.6666667
179   -7.6666667
180   -3.3333333
181   -2.3333333
182    9.0000000
183    0.6666667
184    0.3333333
185   -2.6666667
186    1.0000000
187   -1.6666667
188    4.0000000
189    1.0000000
190   -0.6666667
191   -3.6666667
192    7.3333333
193    6.0000000
194    6.6666667
195   -6.6666667
196   -0.3333333
197  -10.0000000
198   -5.0000000
199   -5.3333333
200    4.3333333
201   -7.3333333
202    2.0000000
203    1.6666667
204    5.3333333
205    6.0000000
206    3.0000000
207    4.0000000
208   -1.3333333
209   -2.0000000
210    2.6666667
211   -2.6666667
212  -14.3333333
213   -0.6666667
214    6.6666667
215   -2.0000000
216   -3.3333333
217   -6.0000000
218    8.6666667
219   -4.0000000
220   -1.6666667
221    2.0000000
222   -1.6666667
223    0.6666667
224   -8.3333333
225    7.6666667
226    2.0000000
227   -0.6666667
228    4.3333333
229   11.6666667
230    1.6666667
231    0.3333333
232    0.0000000
233    4.6666667
234   -3.3333333
235   -3.6666667
236   -3.6666667
237    2.0000000
238   11.3333333
239   -3.6666667
240    1.3333333
241   -6.3333333
242   -2.0000000
243    0.6666667
244    0.6666667
245    0.0000000
246   -6.6666667
247   -3.0000000
248    7.3333333
249   -1.6666667
250   -1.3333333
251    1.3333333
252   -1.0000000
253    0.6666667
254   -2.3333333
255    5.6666667
256    5.3333333
257   -2.3333333
258   -7.0000000
259    5.3333333
260    1.6666667
261    3.0000000
262   -5.3333333
263    8.0000000
264   -2.0000000
265   -1.0000000
266   -3.6666667
267   12.6666667
268   -1.3333333
269    2.3333333
270   -1.0000000
271    2.6666667
272   -2.6666667
273   -3.3333333
274   -1.6666667
275    0.6666667
276    0.0000000
277   -1.6666667
278    3.6666667
279    1.6666667
280    4.0000000
281   -2.6666667
282   -1.3333333
283    7.6666667
284    1.3333333
285    7.3333333
286    1.6666667
287    1.6666667
288    2.0000000
289    1.6666667
290    9.0000000
291    2.6666667
292   -1.3333333
293    6.0000000
294    1.6666667
295   -5.0000000
296    6.6666667
297   -7.3333333
298    2.0000000
299   -0.3333333
300   -7.3333333
301    1.3333333
302    4.6666667
303    0.0000000
304   -7.6666667
305   -5.3333333
306    1.6666667
307    0.3333333
308   -0.6666667
309    0.3333333
310   -1.0000000
311    0.3333333
312    5.0000000
313    0.6666667
314    1.0000000
315    1.3333333
316    1.3333333
317   -2.0000000
318    0.6666667
319    2.0000000
320    7.6666667
321    3.0000000
322    1.0000000
323    2.3333333
324    3.6666667
325    4.0000000
326    4.0000000
327    5.0000000
328   -3.0000000
329    4.0000000
330   -2.6666667
331    0.6666667
332    3.0000000
333    0.3333333
334   -0.6666667
335   -7.3333333
336   -1.6666667
337    7.6666667
338   -3.3333333
339    0.3333333
340    4.0000000
341    6.0000000
342   -6.6666667
343   -6.3333333
344   -4.0000000
345   -9.3333333
346   -3.3333333
347    2.6666667
348    3.0000000
349   -8.0000000
350    0.6666667
351   -4.0000000
352    3.3333333
353    2.6666667
354   -2.0000000
355    7.6666667
356    0.0000000
357   -3.0000000
358    2.3333333
359    1.3333333
360    1.6666667
361    3.0000000
362   -3.6666667
363   -0.3333333
364   -2.3333333
365   -2.3333333
366    1.0000000
367   -5.3333333
368    6.6666667
369    6.6666667
370    4.6666667
371    2.6666667
372   -5.3333333
373   -3.6666667
374    5.6666667
375    1.3333333
376   -0.3333333
377   10.3333333
378   -5.3333333
379    5.0000000
380   -3.3333333
381    0.0000000
382   -6.3333333
383   -2.3333333
384   -5.6666667
385    0.0000000
386   -1.0000000
387    6.6666667
388    4.3333333
389    2.6666667
390    0.0000000
391    9.3333333
392   -4.6666667
393   10.0000000
394   -7.6666667
395    4.3333333
396  -10.3333333
397   -2.6666667
398    7.6666667
399   -4.0000000
400   -4.6666667
401    2.6666667
402   -3.0000000
403    0.3333333
404    0.6666667
405    1.3333333
406   -4.6666667
407    3.0000000
408   -0.6666667
409    3.3333333
410    3.3333333
411    9.3333333
412   -1.6666667
413    3.6666667
414   -7.0000000
415   -3.0000000
416    4.0000000
417   -0.3333333
418   -1.6666667
419    3.3333333
420   -1.6666667
421    1.3333333
422   -3.3333333
423   10.3333333
424   -8.0000000
425   -3.0000000
426    1.6666667
427    9.6666667
428   -4.0000000
429    1.3333333
430    5.3333333
431    1.0000000
432    7.0000000
433   -9.0000000
434   -0.3333333
435    3.3333333
436    6.6666667
437   -2.6666667
438    2.3333333
439   -3.6666667
440   -4.3333333
441   -6.3333333
442    2.6666667
443    0.3333333
444    6.0000000
445    1.0000000
446   -6.0000000
447    4.0000000
448    9.6666667
449    4.0000000
450    2.0000000
451   -0.3333333
452   -5.6666667
453    4.3333333
454    1.3333333
455   -1.3333333
456    5.0000000
457   -4.3333333
458    1.6666667
459   -4.6666667
460   -2.6666667
461    0.6666667
462   -1.0000000
463    5.6666667
464   -0.3333333
465  -10.3333333
466   -8.6666667
467   -5.0000000
468   -0.6666667
469   -5.3333333
470   -5.6666667
471   -5.0000000
472   -5.0000000
473    1.0000000
474   -4.6666667
475    2.6666667
476   -6.0000000
477    0.0000000
478    7.6666667
479    7.3333333
480    9.3333333
481    0.3333333
482   -2.0000000
483   -6.0000000
484    4.0000000
485    3.6666667
486   -4.0000000
487    1.0000000
488    4.6666667
489   -8.3333333
490    1.6666667
491   -2.6666667
492   -1.6666667
493   -2.0000000
494  -10.0000000
495   -0.6666667
496    2.3333333
497    3.0000000
498    2.0000000
499   -5.6666667
500   -2.3333333
501    4.0000000
502    4.6666667
503    3.6666667
504   -4.3333333
505    4.6666667
506   -7.6666667
507    9.0000000
508   -1.0000000
509    1.0000000
510    1.3333333
511    5.6666667
512    0.3333333
513   -3.0000000
514   -0.6666667
515    6.0000000
516    4.3333333
517    0.3333333
518   -2.0000000
519   -1.6666667
520    1.6666667
521   -1.3333333
522    0.3333333
523    1.3333333
524   -3.0000000
525    6.6666667
526    6.6666667
527   -3.6666667
528    1.6666667
529    7.6666667
530    3.0000000
531    9.0000000
532   -2.6666667
533    5.0000000
534   -5.0000000
535   -8.3333333
536    8.6666667
537    7.0000000
538    4.6666667
539   10.6666667
540    0.3333333
541   -3.6666667
542    3.3333333
543    3.6666667
544   -0.6666667
545   -6.0000000
546    5.0000000
547   -4.0000000
548    6.3333333
549   -0.3333333
550    0.3333333
551   -2.0000000
552   -3.3333333
553   -1.0000000
554    2.6666667
555    7.3333333
556    5.3333333
557   -5.3333333
558    0.6666667
559    4.3333333
560   -8.6666667
561   -2.0000000
562   -7.6666667
563   -1.6666667
564    2.6666667
565   -3.6666667
566   -0.6666667
567    2.6666667
568   -8.6666667
569   -2.6666667
570    2.3333333
571   -5.6666667
572   -8.0000000
573    5.6666667
574   -1.6666667
575   -4.6666667
576    0.3333333
577   -6.6666667
578    5.3333333
579    6.3333333
580    4.6666667
581   -3.3333333
582   -0.6666667
583    0.6666667
584    3.3333333
585    5.6666667
586    8.3333333
587   -7.6666667
588   -2.0000000
589   -4.0000000
590    1.6666667
591    0.6666667
592   -7.6666667
593    8.0000000
594    9.6666667
595    2.3333333
596   -8.0000000
597   -1.3333333
598   -0.3333333
599    2.0000000
600   -3.0000000
601    2.6666667
602    8.0000000
603    4.6666667
604   -4.6666667
605    1.0000000
606   -2.6666667
607    1.0000000
608    4.3333333
609   -8.0000000
610    1.3333333
611   -5.0000000
612   -0.6666667
613    6.0000000
614    0.3333333
615   -7.6666667
616   -3.6666667
617   -7.0000000
618   -3.6666667
619  -11.3333333
620    7.6666667
621   -9.3333333
622   -6.6666667
623   -4.3333333
624   -2.3333333
625    0.3333333
626    7.3333333
627   -2.0000000
628   -1.3333333
629    1.0000000
630    2.3333333
631   -2.0000000
632    4.0000000
633    0.3333333
634   -3.6666667
635    3.6666667
636   -0.6666667
637   -3.6666667
638    6.0000000
639    2.0000000
640   -3.6666667
641    3.6666667
642   -5.6666667
643    1.0000000
644   -4.3333333
645  -12.0000000
646    1.3333333
647    2.0000000
648   -3.0000000
649   -4.0000000
650    4.6666667
651   -1.0000000
652   -1.0000000
653    1.6666667
654   -0.3333333
655    8.6666667
656   -5.6666667
657   -8.3333333
658   -3.3333333
659   -1.0000000
660   -4.0000000
661   -2.3333333
662    2.0000000
663    5.6666667
664   -5.3333333
665   -5.6666667
666    0.3333333
667    8.3333333
668   -5.6666667
669   -5.0000000
670   -1.3333333
671    6.0000000
672   -2.0000000
673    5.0000000
674    1.3333333
675    8.6666667
676   -3.0000000
677    8.3333333
678   -3.3333333
679    2.0000000
680    4.0000000
681    6.3333333
682    1.0000000
683    8.6666667
684   -1.0000000
685    4.3333333
686   -5.6666667
687   -1.0000000
688    5.0000000
689    7.3333333
690    3.3333333
691   -2.0000000
692   -4.6666667
693    2.0000000
694    6.0000000
695   -1.0000000
696    2.0000000
697    5.3333333
698   -9.6666667
699   -6.0000000
700   -2.0000000
701    4.6666667
702   -4.0000000
703    3.0000000
704    1.6666667
705   -7.6666667
706   -1.0000000
707   -4.3333333
708   10.6666667
709   -0.3333333
710    0.6666667
711    8.3333333
712   -4.0000000
713    6.3333333
714    5.6666667
715   -8.3333333
716    3.6666667
717    2.0000000
718    2.6666667
719  -10.3333333
720    2.0000000
721   -4.3333333
722    2.6666667
723    9.0000000
724   -8.0000000
725    6.0000000
726   -7.6666667
727    3.0000000
728   -3.6666667
729    2.0000000
730    5.3333333
731    1.3333333
732   -2.3333333
733   -6.6666667
734    7.6666667
735   -5.3333333
736   -3.6666667
737   -8.3333333
738    0.0000000
739   -6.0000000
740    9.3333333
741    1.3333333
742   -5.6666667
743   -3.6666667
744   -6.6666667
745   -6.0000000
746   -4.6666667
747   -4.3333333
748   -3.3333333
749    2.3333333
750   -1.0000000
751   -1.3333333
752   -3.3333333
753   -0.6666667
754    1.3333333
755    2.0000000
756   -6.6666667
757    1.3333333
758   -0.3333333
759    6.0000000
760   -6.0000000
761    2.0000000
762    0.3333333
763   -4.0000000
764   -2.6666667
765    0.6666667
766    5.6666667
767   -7.0000000
768    2.0000000
769   -0.3333333
770    5.0000000
771    1.0000000
772   -1.0000000
773    2.3333333
774    2.0000000
775    7.0000000
776    4.0000000
777   -3.0000000
778   -0.6666667
779   -8.6666667
780    2.6666667
781    2.6666667
782    3.3333333
783    5.6666667
784   -6.0000000
785    7.6666667
786    1.3333333
787  -12.3333333
788   -1.3333333
789    2.0000000
790   -2.3333333
791    5.0000000
792    2.3333333
793   -2.6666667
794    0.6666667
795    6.3333333
796    5.6666667
797    2.6666667
798   -5.6666667
799   -6.0000000
800   -1.6666667
801   -7.0000000
802   -4.0000000
803   -8.0000000
804   -2.0000000
805   -4.0000000
806    2.0000000
807    2.0000000
808   -3.6666667
809    3.6666667
810    1.0000000
811   -5.3333333
812   -2.6666667
813    2.3333333
814    4.0000000
815    6.6666667
816   -2.6666667
817   -1.6666667
818   -3.6666667
819    0.6666667
820    0.0000000
821   -7.3333333
822    3.0000000
823    2.6666667
824    2.3333333
825   -4.6666667
826    5.3333333
827    5.3333333
828   -6.0000000
829   10.3333333
830   -8.3333333
831   -2.3333333
832   -2.3333333
833   -2.3333333
834   15.3333333
835   -9.3333333
836   -7.0000000
837    0.3333333
838    1.0000000
839   -7.3333333
840   -7.3333333
841    1.3333333
842    0.6666667
843   -5.3333333
844   -0.6666667
845   -1.6666667
846    3.6666667
847   -4.0000000
848    0.6666667
849   -0.3333333
850    0.6666667
851   -0.6666667
852    5.0000000
853    3.6666667
854    1.6666667
855    4.3333333
856   -1.0000000
857   -2.0000000
858    0.6666667
859    1.3333333
860    0.6666667
861    6.6666667
862    3.6666667
863    2.3333333
864    3.3333333
865    8.6666667
866    8.3333333
867   -1.6666667
868   -2.6666667
869    3.3333333
870   -4.0000000
871    1.3333333
872    0.0000000
873   -2.0000000
874    3.0000000
875    6.6666667
876   -1.0000000
877   -0.6666667
878    4.0000000
879    0.0000000
880    4.6666667
881   -1.0000000
882    1.6666667
883   -4.6666667
884    0.3333333
885   -2.0000000
886    1.3333333
887    1.0000000
888   -1.6666667
889    0.6666667
890    0.0000000
891   -2.3333333
892    3.0000000
893   -3.6666667
894   -5.6666667
895   -9.0000000
896    3.0000000
897   -2.3333333
898    4.3333333
899    3.6666667
900    3.3333333
901    5.3333333
902    0.0000000
903    5.6666667
904   -4.3333333
905   -1.0000000
906    4.3333333
907   -4.6666667
908   -1.3333333
909    3.0000000
910   10.0000000
911  -11.0000000
912    5.0000000
913    3.0000000
914    4.6666667
915   -7.3333333
916    3.3333333
917   -1.6666667
918    2.6666667
919    2.3333333
920   -2.3333333
921    8.6666667
922   -0.3333333
923   -0.6666667
924    2.6666667
925   -0.6666667
926   10.6666667
927    4.6666667
928    2.0000000
929    8.6666667
930    5.0000000
931    2.0000000
932    1.3333333
933    4.0000000
934   -0.3333333
935   -6.0000000
936   -1.3333333
937   -3.6666667
938   -5.6666667
939    2.3333333
940    0.3333333
941   -2.3333333
942   -0.3333333
943   -7.6666667
944   -2.0000000
945   -6.3333333
946   -4.3333333
947   -6.0000000
948    8.0000000
949   -2.0000000
950   -5.3333333
951   -6.3333333
952    0.0000000
953    5.0000000
954   -4.3333333
955    0.0000000
956   -0.3333333
957    3.0000000
958    2.3333333
959    3.0000000
960   -8.0000000
961    3.0000000
962   -4.0000000
963    1.6666667
964    0.6666667
965    1.3333333
966   -4.0000000
967    1.6666667
968   -4.0000000
969    7.0000000
970   -7.3333333
971   -6.6666667
972   -2.6666667
973   -4.0000000
974   -2.6666667
975    7.0000000
976    6.3333333
977   -3.0000000
978    6.6666667
979   -4.0000000
980   -3.0000000
981    1.3333333
982   -4.6666667
983   -1.0000000
984    0.6666667
985    4.3333333
986   -6.6666667
987   -1.3333333
988   -9.0000000
989   -6.3333333
990    4.6666667
991    8.3333333
992   -1.6666667
993    0.0000000
994   -1.6666667
995    0.0000000
996    7.3333333
997   -1.0000000
998  -13.6666667
999    4.0000000
1000  -2.6666667

The permutation test comparing the tipping behaviour between males and females was conducted by randomly shuffling the gender labels 1,000 times and calculating the difference in mean tip amounts for each shuffle. The resulting distribution of differences varied around zero, with values like -7.33, 1.00, -2.00, and 3.66 observed. This distribution suggests that any observed difference in tipping behaviour between males and females could largely be attributed to random variation, rather than a true underlying difference in tipping habits based on gender.

Plotting the results of the Permutation Test

gf_histogram(~ diffmean, data = perm_test_gender, bins = 30) %>%
  gf_labs(
    title = "Permutation Test for Tipping Differences: Males vs. Females",
    x = "Difference in Mean Tip Amount",
    y = "Count"
  )

The permutation test for tipping differences between males and females shows a symmetric distribution centered around zero. The differences in mean tipping amounts vary from approximately -10 to 10 rupees. This indicates that, based on the resampled data, the observed differences in tipping between males and females are likely due to random chance. The distribution does not suggest a strong or consistent difference in tipping behaviour between the two genders.

Observed difference for Males vs Females

observed_diff_gender <- diffmean(Tip ~ Gender, data = tip_modified)
observed_diff_gender
diffmean 
      -2 

The observed difference in mean tips between males and females is -2 rupees. This indicates that, on average, males tend to tip 2 rupees less than females in the dataset.

Calculating the p-value

p_value_gender <- prop(~ (abs(diffmean) >= abs(observed_diff_gender)), data = perm_test_gender)
p_value_gender
prop_TRUE 
    0.699 

The permutation test conducted to assess the difference in tipping behaviour between males and females resulted in a p-value of 0.697. This p-value is quite high, indicating that the observed difference in mean tips between males and females (-2 rupees) is not statistically significant. In other words, there is a 69.7% probability that the observed difference could have occurred by random chance. Therefore, we do not have enough evidence to conclude that there is a significant difference in tipping behaviour between males and females based on this dataset.

Summary of Results for the Tipping Behaviour Research Experiment

The research experiment aimed to determine if there was a significant difference in tipping behaviour between vegetarians and non-vegetarians, and between male and female students at MAHE Bengaluru. The following statistical tests were conducted:

Two-Sample t-Test (Welch’s t-test):

  1. Vegetarians vs. Non-Vegetarians: The two-sample t-test comparing the mean tip amounts between vegetarians and non-vegetarians resulted in a p-value of 0.6169. This indicates no statistically significant difference in the average tip amount between the two dietary groups, as the p-value is much higher than the typical threshold of 0.05.

  2. Males vs. Females: The t-test comparing the mean tip amounts between males and females resulted in a p-value of 0.6679. This also suggests no significant difference in tipping behaviour based on gender.

Wilcoxon Rank-Sum Test:

  1. Vegetarians vs. Non-Vegetarians: The Wilcoxon test, a non-parametric alternative to the t-test, resulted in a p-value of 0.8327. This further supports the t-test results, indicating no significant difference between vegetarians and non-vegetarians in terms of tipping behaviour.

  2. Males vs. Females: The Wilcoxon test comparing males and females resulted in a p-value of 0.4221, which also suggests no statistically significant difference between the two genders.

Permutation Test:

  1. Vegetarians vs. Non-Vegetarians: The permutation test comparing tipping behaviour between vegetarians and non-vegetarians resulted in a p-value of 0.675, confirming that the observed difference in mean tip amounts of approximately 2.33 rupees is likely due to random variation and not a significant underlying difference.

  2. Males vs. Females: The permutation test for tipping differences between males and females resulted in a p-value of 0.697. The observed difference in mean tip amounts (-2 rupees, with females tipping slightly more on average) is also likely due to random variation.

Conclusion:

Based on the results of these tests, there is no evidence to suggest that either dietary preference (vegetarian vs. non-vegetarian) or gender (male vs. female) significantly impacts tipping behaviour in this dataset. The high p-values across all tests indicate that the observed differences in tipping amounts are likely due to chance. Therefore, the initial hypotheses that non-vegetarians might tip more than vegetarians, or that one gender tips more than the other, are not supported by the data.