What’s the proportion of people who believe in god?

Author

Diya Bijoy

Published

November 4, 2025

R Packages Setup

library(ggformula)
Loading required package: ggplot2
Loading required package: scales
Loading required package: ggridges

New to ggformula?  Try the tutorials: 
    learnr::run_tutorial("introduction", package = "ggformula")
    learnr::run_tutorial("refining", package = "ggformula")
library(janitor)

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

    chisq.test, fisher.test
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 objects are masked from 'package:dplyr':

    count, do, tally
The following object is masked from 'package:Matrix':

    mean
The following object is masked from 'package:scales':

    rescale
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(naniar)
library(skimr)

Attaching package: 'skimr'
The following object is masked from 'package:naniar':

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

    n_missing
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ lubridate 1.9.4     ✔ tibble    3.3.0
✔ purrr     1.1.0     ✔ tidyr     1.3.1
✔ readr     2.1.5     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ readr::col_factor() masks scales::col_factor()
✖ mosaic::count()     masks dplyr::count()
✖ purrr::cross()      masks mosaic::cross()
✖ purrr::discard()    masks scales::discard()
✖ mosaic::do()        masks dplyr::do()
✖ tidyr::expand()     masks Matrix::expand()
✖ dplyr::filter()     masks stats::filter()
✖ dplyr::lag()        masks stats::lag()
✖ tidyr::pack()       masks Matrix::pack()
✖ mosaic::stat()      masks ggplot2::stat()
✖ mosaic::tally()     masks dplyr::tally()
✖ tidyr::unpack()     masks Matrix::unpack()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tinytable)

Attaching package: 'tinytable'

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

    theme_void
library(visdat)
library(crosstable)

Attaching package: 'crosstable'

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

    compact
library(RColorBrewer)
library(naniar)
library(GGally)
library(ggplot2)
library(correlation)

Attaching package: 'correlation'

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

    cor_test
library(dplyr)
library(RColorBrewer)
library(DT)
library(infer)

Attaching package: 'infer'

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

    prop_test, t_test
library(resampledata)

Attaching package: 'resampledata'

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

    Titanic
library(openintro)
Loading required package: airports
Loading required package: cherryblossom
Loading required package: usdata

Attaching package: 'openintro'

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

    tips

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

    dotPlot

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

    ethanol, lsegments
library(vcd)
Loading required package: grid

Attaching package: 'vcd'

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

    mplot
library(visStatistics)

Reading the file

belief <- read.csv("5-believe_in_god.csv")
glimpse(belief)
Rows: 47
Columns: 3
$ Name           <chr> "Sanjana", "Tathasthu", "Vaibhav", "Siddharth", "Ashik"…
$ Gender         <chr> "Female", "Male", "Male", "Male", "Male", "Female", "Fe…
$ Believe_in_God <chr> "Yes", "Yes", "Yes", "Yes", "No", "Yes", "Yes", "No", "…

Munging

belief_modified <- belief %>%
  mutate(across(where(is.character), as.factor))%>%
  dplyr::relocate(where(is.factor), .after = Name)
glimpse(belief_modified)
Rows: 47
Columns: 3
$ Name           <fct> Sanjana, Tathasthu, Vaibhav, Siddharth, Ashik, Kshirab,…
$ Gender         <fct> Female, Male, Male, Male, Male, Female, Female, Female,…
$ Believe_in_God <fct> Yes, Yes, Yes, Yes, No, Yes, Yes, No, Yes, No, NA, No, …

Removing Missing Data

belief_modified2 <- belief_modified %>% drop_na()
belief_modified2
                                   Name Gender Believe_in_God
1                               Sanjana Female            Yes
2                             Tathasthu   Male            Yes
3                               Vaibhav   Male            Yes
4                             Siddharth   Male            Yes
5                                 Ashik   Male             No
6                               Kshirab Female            Yes
7                               Niyosha Female            Yes
8                                Charvi Female             No
9                                 Anoti Female            Yes
10                                Dhruv   Male             No
11                               Maanya Female             No
12                               Aaksha Female            Yes
13                                Adhil   Male             No
14                              Aradhya   Male            Yes
15                             Prathana Female            Yes
16                              Ashmita Female            Yes
17                               Ishita Female             No
18                                Rishi   Male             No
19 Arnav Kodhandapani  Anupama Srikanth   Male             No
20                               Nitish   Male            Yes
21                             Avanilka Female            Yes
22                             Lakshita Female            Yes
23                              Nandana Female            Yes
24                              Mridula Female            Yes
25                                Shiva   Male             No
26                                 Diya Female            Yes
27                              Kanishk   Male             No
28                              Samaraj   Male            Yes
29                                Nipun   Male            Yes
30                            Vasudhara Female             No
31                               Aditya   Male             No
32                                Risha Female            Yes
33                              Jashith   Male             No
34                               Swetha Female            Yes
35                                Rishi   Male            Yes
36                                Manal Female            Yes
37                              Shruthi Female            Yes
38                               Aditya   Male             No
39                              Ashmita Female             No
40                             Krithika Female            Yes
41                                 Diya Female            Yes

Examining the Data

belief_modified2 %>%
  count(Believe_in_God)
  Believe_in_God  n
1             No 15
2            Yes 26
belief_modified2 %>%
  group_by(Gender) %>% 
  count(Believe_in_God)
# A tibble: 4 × 3
# Groups:   Gender [2]
  Gender Believe_in_God     n
  <fct>  <fct>          <int>
1 Female No                 5
2 Female Yes               18
3 Male   No                10
4 Male   Yes                8

Visualising Data

belief_modified2 %>%
  gf_bar(~Believe_in_God, fill = ~ Believe_in_God) %>%
  gf_labs(
    x = "Do you believe in god?",
    y = "Count",
    title = "Proportion of yes & no"
  ) %>% 
  gf_refine(scale_fill_brewer(palette = "Set2"))

belief_modified2 %>%
  gf_bar(~Believe_in_God | Gender, fill = ~ Believe_in_God) %>%
  gf_labs(
    x = "Do you believe in god?",
    y = "Count",
    title = "Proportion of Yes or No",
    subtitle = "Faceted by Gender"
  ) %>% 
  gf_refine(scale_fill_brewer(palette = "Set1"))

belief_modified2 %>%
  gf_bar(~Gender, fill = ~ Believe_in_God, position = "stack") %>%
  gf_labs(
    x = "Gender",
    y = "Count",
    title = "Count of Belief in God"
  ) %>%
  gf_refine(scale_fill_brewer(palette = "Set1"))

belief_modified2 %>%
  gf_bar(~Gender, fill = ~ Believe_in_God, position = "fill") %>%
  gf_labs(
    x = "Gender",
    y = "Count",
    title = "Count of Belief in God"
  ) %>%
  gf_refine(scale_fill_brewer(palette = "Set1"))

Prop Test: Do a majority of the people believe in god?

H0: Half of the people believe in God (p = 0.5)

H1: The proportion of people who believe in God is not equal to 0.5.

mosaic::binom.test(~Believe_in_God, data = belief_modified2, success = "Yes") %>% 
  broom::tidy()
# A tibble: 1 × 7
  estimate statistic p.value parameter conf.low conf.high alternative
     <dbl>     <dbl>   <dbl>     <dbl>    <dbl>     <dbl> <chr>      
1    0.634        26   0.117        41    0.469     0.779 two.sided  

Inference:-

  • The p value > 0.05, which means we fail to reject the Null Hypothesis.
  • There isn’t enough evidence to say that the proportion of people who believe in God is different from 50%.
  • Belief in God is roughly balanced - half the people believe and half don’t.

Chisq.test: Is there a difference in the proportion of males and females who believe in god?

H0: Proportion of males who believe in god is equal to the true proportion of females who believe in god.

H1: There is a difference between the proportion of males and females who believe in god.

contingency_table <- vcd::structable(Believe_in_God~ Gender,
  data = belief_modified2
)
contingency_table
       Believe_in_God No Yes
Gender                      
Female                 5  18
Male                  10   8
gss_vcd_table <- vcd::structable(Gender ~ Believe_in_God,
  data = belief_modified2)

gss_vcd_table %>%
  vcd::mosaic(
    gp = shading_max, direction = "v", # Changed shading function
    main = "Gender vs Belief",
    legend = TRUE,
    labeling = labeling_border(
      varnames = c("F", "F"),
      rot_labels = c(90, 0, 0, 0),
      just_labels = c("left", "left", "left", "right")
    )
  )

xq_test_object <- chisq.test(contingency_table)
xq_test_object

    Pearson's Chi-squared test with Yates' continuity correction

data:  contingency_table
X-squared = 3.6262, df = 1, p-value = 0.05688
xq_test_object %>%
  broom::tidy() %>%
  select(statistic) %>%
  as.numeric() -> X_squared_observed
X_squared_observed
[1] 3.626225
X_squared_critical <- qchisq(
  p = .05,
  df = (2 - 1) * (2 - 1), # (nrows-1) * (ncols-1)
  lower.tail = FALSE
)
X_squared_critical
[1] 3.841459
mosaic::xqchisq(
  p = 0.95, df = 1,
  return = c("plot"), verbose = F,
  system = "gg"
) %>%
  gf_labs(
    x = "Chi-Square Value", 
    title = "Critical and Observed Chi-Square Values"
  ) %>%
  gf_vline(
    xintercept = X_squared_observed,
    color = "red", linewidth = 1
  ) %>%
  gf_vline(
    xintercept = X_squared_critical,
    color = "dodgerblue", linewidth = 1
  ) %>%
  gf_annotate(
    x = X_squared_observed + 0.2, y = 0.05,
    geom = "label", label = "Observed\nChi-Square",
    fill = "red", alpha = 0.3
  ) %>%
  gf_annotate(
    x = X_squared_critical - 0.5, y = 0.05,
    geom = "label", label = "Critical\nChi-Square",
    fill = "lightblue"
  )

Inference:

  • The p value = 0.056, so we fail to reject the Null Hypothesis.
  • This means belief in God does not differ between males and females — both genders showed similar levels of belief.

Conclusion:

To sum up, there is an equal proportion of people who believe in god. A chi-square test was conducted to see if opinions differ from men to women. The test showed no significant difference as both males and females. Overall, we see that belief in god between males and females does not differ significantly, both genders show similar levels of belief.