continuous <- c("children_14", "adults_15_60", "senior_citizens", "Total_Family_Members")
summary(data[continuous])
## children_14 adults_15_60 senior_citizens Total_Family_Members
## Min. :0.000 Min. : 0.000 Min. :0.0000 Min. : 0.000
## 1st Qu.:0.000 1st Qu.: 2.000 1st Qu.:0.0000 1st Qu.: 3.000
## Median :1.000 Median : 2.000 Median :0.0000 Median : 4.000
## Mean :1.161 Mean : 2.781 Mean :0.1547 Mean : 4.096
## 3rd Qu.:2.000 3rd Qu.: 4.000 3rd Qu.:0.0000 3rd Qu.: 5.000
## Max. :7.000 Max. :12.000 Max. :5.0000 Max. :16.000
library(pastecs)
## Warning: package 'pastecs' was built under R version 4.0.3
##
## Attaching package: 'pastecs'
## The following object is masked from 'package:tidyr':
##
## extract
## The following objects are masked from 'package:dplyr':
##
## first, last
res <- (stat.desc(data[continuous]))
res <- round(res, 2)
View(res)
data <- data %>% mutate(City = as.factor(City))
levels(data$City) <- list(Delhi = "delhi", Puri = "puri", Cuttuck = "cuttack", Panji = "panji", Patna = "patna", Bhubaneshwar = "bhubaneshwar", Ghaziabad = "ghaziabad", Aurangabad = "aurangabad", Jammu = "jammu", Rishikesh = "rishikesh", Chennai = "chennai", Jaipur = "jaipur", Mumbai = "mumbai_aasra", Mumbai = "mumbai_sms", Delhi_Cant = "delhi_cantonment", Varanasi = "varanasi_kgn")
city_child <- data %>% group_by(City) %>%
summarise(average = round(mean(children_14),0), max_children = max(children_14))
city_adult <- data %>% group_by(City) %>%
summarise(average = round(mean(adults_15_60),0), max_adults = max(adults_15_60))
city_senior <- data %>% group_by(City) %>%
summarise(average = round(mean(senior_citizens),0), max_seniors = max(senior_citizens))
city_family <- data %>% group_by(City) %>%
summarise(average = round(mean(Total_Family_Members),0), max_members = max(Total_Family_Members))
city_child
## # A tibble: 15 x 3
## City average max_children
## <fct> <dbl> <dbl>
## 1 Delhi 2 6
## 2 Puri 1 4
## 3 Cuttuck 1 6
## 4 Panji 1 7
## 5 Patna 2 7
## 6 Bhubaneshwar 1 5
## 7 Ghaziabad 1 5
## 8 Aurangabad 1 7
## 9 Jammu 1 7
## 10 Rishikesh 1 5
## 11 Chennai 1 4
## 12 Jaipur 1 7
## 13 Mumbai 1 6
## 14 Delhi_Cant 0 4
## 15 Varanasi 1 6
city_adult
## # A tibble: 15 x 3
## City average max_adults
## <fct> <dbl> <dbl>
## 1 Delhi 3 10
## 2 Puri 3 7
## 3 Cuttuck 3 9
## 4 Panji 2 9
## 5 Patna 3 9
## 6 Bhubaneshwar 3 8
## 7 Ghaziabad 3 8
## 8 Aurangabad 3 8
## 9 Jammu 3 8
## 10 Rishikesh 3 9
## 11 Chennai 2 7
## 12 Jaipur 3 10
## 13 Mumbai 3 12
## 14 Delhi_Cant 3 8
## 15 Varanasi 2 7
city_senior
## # A tibble: 15 x 3
## City average max_seniors
## <fct> <dbl> <dbl>
## 1 Delhi 0 2
## 2 Puri 0 5
## 3 Cuttuck 0 2
## 4 Panji 0 2
## 5 Patna 1 2
## 6 Bhubaneshwar 0 2
## 7 Ghaziabad 0 2
## 8 Aurangabad 0 2
## 9 Jammu 0 2
## 10 Rishikesh 0 2
## 11 Chennai 0 2
## 12 Jaipur 0 3
## 13 Mumbai 0 3
## 14 Delhi_Cant 0 2
## 15 Varanasi 0 2
city_family
## # A tibble: 15 x 3
## City average max_members
## <fct> <dbl> <dbl>
## 1 Delhi 5 16
## 2 Puri 4 9
## 3 Cuttuck 4 15
## 4 Panji 3 10
## 5 Patna 5 13
## 6 Bhubaneshwar 4 12
## 7 Ghaziabad 5 10
## 8 Aurangabad 4 14
## 9 Jammu 4 10
## 10 Rishikesh 4 9
## 11 Chennai 3 9
## 12 Jaipur 4 10
## 13 Mumbai 4 13
## 14 Delhi_Cant 4 13
## 15 Varanasi 3 9
colnames(data)[38] <- "Income"
data$Income <- factor(data$Income, ordered = TRUE, levels = c("less_than_INR_2250", "INR_2251_INR_5000", "INR_5001_INR_10000", "INR_10001_INR_20000", "less_than_INR_20000"))
levels(data$Income)
## [1] "less_than_INR_2250" "INR_2251_INR_5000" "INR_5001_INR_10000"
## [4] "INR_10001_INR_20000" "less_than_INR_20000"
ggplot(data, aes(x = Income, y = Total_Family_Members, fill = Income)) +
geom_point(aes(color = Income), position = position_jitter(width = .15), size = .5, alpha = 0.8) +
coord_cartesian(ylim = c(0, 15)) +
geom_boxplot() +
geom_flat_violin(position = position_nudge(x = .2, y = 0), alpha = .8) +
theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1) )
#Ordinal Logistic Regression
##############################################
library(foreign)
library(MASS)
## Warning: package 'MASS' was built under R version 4.0.4
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
library(Hmisc)
library(reshape2)
library(rms)
## Warning: package 'rms' was built under R version 4.0.4
## Loading required package: SparseM
## Warning: package 'SparseM' was built under R version 4.0.4
##
## Attaching package: 'SparseM'
## The following object is masked from 'package:base':
##
## backsolve
##
## Attaching package: 'rms'
## The following object is masked from 'package:pastecs':
##
## specs
ggplot(data, aes(x = Income, y = Total_Family_Members, fill = Income)) +
coord_cartesian(ylim = c(0, 15)) +
geom_boxplot(size = .75) +
facet_grid(~ Category, margins = TRUE) +
theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))
ggplot(data, aes(x = Income, y = Total_Family_Members, fill = Income)) +
coord_cartesian(ylim = c(0, 15)) +
geom_boxplot(size = .75) +
facet_grid(~ Nature_of_work, margins = TRUE) +
theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1))
levels(data$Income)
## [1] "less_than_INR_2250" "INR_2251_INR_5000" "INR_5001_INR_10000"
## [4] "INR_10001_INR_20000" "less_than_INR_20000"
olr <- polr(formula = Income ~ Total_Family_Members + Nature_of_work + children_14 + adults_15_60, data = data, Hess = TRUE)
summary(olr)
## Call:
## polr(formula = Income ~ Total_Family_Members + Nature_of_work +
## children_14 + adults_15_60, data = data, Hess = TRUE)
##
## Coefficients:
## Value Std. Error t value
## Total_Family_Members 0.3044 0.04373 6.963
## Nature_of_workitinerant_waste_picker -0.4591 0.07714 -5.951
## Nature_of_workmunicipal_contractor_collector 0.4843 0.10633 4.555
## Nature_of_workothers 0.7890 0.14359 5.495
## Nature_of_workstreet_sweeper 1.1093 0.07976 13.907
## Nature_of_workwaste_picker_at_a_landfill -1.0864 0.08490 -12.797
## Nature_of_workwaste_picker_working_for_an_aggregator -0.1175 0.09230 -1.273
## Nature_of_workwastepicker_working_at_mrf 0.3782 0.08633 4.381
## children_14 -0.2509 0.04684 -5.356
## adults_15_60 0.1239 0.04548 2.724
##
## Intercepts:
## Value Std. Error t value
## less_than_INR_2250|INR_2251_INR_5000 -1.6386 0.0879 -18.6402
## INR_2251_INR_5000|INR_5001_INR_10000 0.1888 0.0820 2.3035
## INR_5001_INR_10000|INR_10001_INR_20000 2.3707 0.0857 27.6755
## INR_10001_INR_20000|less_than_INR_20000 4.8580 0.1028 47.2497
##
## Residual Deviance: 22372.13
## AIC: 22400.13
ctable <- coef(summary(olr))
tab_model(olr)
| Income | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| less_than_INR_2250|INR_2251_INR_5000 | 0.19 | 0.18 – 0.21 | <0.001 |
| INR_2251_INR_5000|INR_5001_INR_10000 | 1.21 | 1.04 – 1.40 | 0.021 |
| INR_5001_INR_10000|INR_10001_INR_20000 | 10.71 | 8.69 – 13.19 | <0.001 |
| INR_10001_INR_20000|less_than_INR_20000 | 128.77 | 97.18 – 170.63 | <0.001 |
| Total_Family_Members | 1.36 | 1.24 – 1.48 | <0.001 |
|
Nature_of_work [itinerant_waste_picker] |
0.63 | 0.54 – 0.73 | <0.001 |
|
Nature_of_work [municipal_contractor_collector] |
1.62 | 1.32 – 2.00 | <0.001 |
| Nature_of_work [others] | 2.20 | 1.66 – 2.92 | <0.001 |
|
Nature_of_work [street_sweeper] |
3.03 | 2.59 – 3.55 | <0.001 |
|
Nature_of_work [waste_picker_at_a_landfill] |
0.34 | 0.29 – 0.40 | <0.001 |
|
Nature_of_work [waste_picker_working_for_an_aggregator] |
0.89 | 0.74 – 1.07 | 0.203 |
|
Nature_of_work [wastepicker_working_at_mrf] |
1.46 | 1.23 – 1.73 | <0.001 |
| children_14 | 0.78 | 0.71 – 0.85 | <0.001 |
| adults_15_60 | 1.13 | 1.04 – 1.24 | 0.006 |
| Observations | 9046 | ||
| R2 Nagelkerke | 0.220 | ||
# add p value
p <- pnorm(abs(ctable[, "t value"]), lower.tail = FALSE) * 2
ctable <- cbind(ctable, "p value" = p)
View(ctable)
#pred
pred.olr <- predict(olr, type="probs")
summary(pred.olr)
## less_than_INR_2250 INR_2251_INR_5000 INR_5001_INR_10000 INR_10001_INR_20000
## Min. :0.0003753 Min. :0.001954 Min. :0.01794 Min. :0.02794
## 1st Qu.:0.0251358 1st Qu.:0.113030 1st Qu.:0.39487 1st Qu.:0.13888
## Median :0.0510048 Median :0.199468 Median :0.45519 Median :0.22510
## Mean :0.0665017 Mean :0.207430 Mean :0.42807 Mean :0.25300
## 3rd Qu.:0.0908006 3rd Qu.:0.292277 3rd Qu.:0.48469 3rd Qu.:0.35779
## Max. :0.3653648 Max. :0.427123 Max. :0.49712 Max. :0.55239
## less_than_INR_20000
## Min. :0.002613
## 1st Qu.:0.014881
## Median :0.027302
## Mean :0.044998
## 3rd Qu.:0.055274
## Max. :0.800728
#marginal effect
library(erer)
## Warning: package 'erer' was built under R version 4.0.4
## Loading required package: lmtest
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.0.4
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Attaching package: 'lmtest'
## The following object is masked from 'package:rms':
##
## lrtest
## Registered S3 methods overwritten by 'car':
## method from
## influence.merMod lme4
## cooks.distance.influence.merMod lme4
## dfbeta.influence.merMod lme4
## dfbetas.influence.merMod lme4
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
x <- ocME(w = olr)
x
## effect.less_than_INR_2250
## Total_Family_Members -0.014
## Nature_of_workitinerant_waste_picker 0.023
## Nature_of_workmunicipal_contractor_collector -0.018
## Nature_of_workothers -0.026
## Nature_of_workstreet_sweeper -0.039
## Nature_of_workwaste_picker_at_a_landfill 0.072
## Nature_of_workwaste_picker_working_for_an_aggregator 0.006
## Nature_of_workwastepicker_working_at_mrf -0.015
## children_14 0.011
## adults_15_60 -0.006
## effect.INR_2251_INR_5000
## Total_Family_Members -0.041
## Nature_of_workitinerant_waste_picker 0.065
## Nature_of_workmunicipal_contractor_collector -0.059
## Nature_of_workothers -0.089
## Nature_of_workstreet_sweeper -0.129
## Nature_of_workwaste_picker_at_a_landfill 0.159
## Nature_of_workwaste_picker_working_for_an_aggregator 0.016
## Nature_of_workwastepicker_working_at_mrf -0.048
## children_14 0.034
## adults_15_60 -0.017
## effect.INR_5001_INR_10000
## Total_Family_Members -0.005
## Nature_of_workitinerant_waste_picker -0.003
## Nature_of_workmunicipal_contractor_collector -0.026
## Nature_of_workothers -0.062
## Nature_of_workstreet_sweeper -0.073
## Nature_of_workwaste_picker_at_a_landfill -0.058
## Nature_of_workwaste_picker_working_for_an_aggregator 0.001
## Nature_of_workwastepicker_working_at_mrf -0.015
## children_14 0.004
## adults_15_60 -0.002
## effect.INR_10001_INR_20000
## Total_Family_Members 0.051
## Nature_of_workitinerant_waste_picker -0.073
## Nature_of_workmunicipal_contractor_collector 0.087
## Nature_of_workothers 0.144
## Nature_of_workstreet_sweeper 0.198
## Nature_of_workwaste_picker_at_a_landfill -0.150
## Nature_of_workwaste_picker_working_for_an_aggregator -0.019
## Nature_of_workwastepicker_working_at_mrf 0.066
## children_14 -0.042
## adults_15_60 0.021
## effect.less_than_INR_20000
## Total_Family_Members 0.009
## Nature_of_workitinerant_waste_picker -0.012
## Nature_of_workmunicipal_contractor_collector 0.017
## Nature_of_workothers 0.033
## Nature_of_workstreet_sweeper 0.044
## Nature_of_workwaste_picker_at_a_landfill -0.022
## Nature_of_workwaste_picker_working_for_an_aggregator -0.003
## Nature_of_workwastepicker_working_at_mrf 0.012
## children_14 -0.007
## adults_15_60 0.004
x$out
## $ME.less_than_INR_2250
## effect error t.value
## Total_Family_Members -0.014 0.002 -6.782
## Nature_of_workitinerant_waste_picker 0.023 0.004 5.260
## Nature_of_workmunicipal_contractor_collector -0.018 0.003 -5.474
## Nature_of_workothers -0.026 0.003 -7.601
## Nature_of_workstreet_sweeper -0.039 0.003 -14.666
## Nature_of_workwaste_picker_at_a_landfill 0.072 0.008 8.989
## Nature_of_workwaste_picker_working_for_an_aggregator 0.006 0.005 1.218
## Nature_of_workwastepicker_working_at_mrf -0.015 0.003 -4.906
## children_14 0.011 0.002 5.273
## adults_15_60 -0.006 0.002 -2.710
## p.value
## Total_Family_Members 0.000
## Nature_of_workitinerant_waste_picker 0.000
## Nature_of_workmunicipal_contractor_collector 0.000
## Nature_of_workothers 0.000
## Nature_of_workstreet_sweeper 0.000
## Nature_of_workwaste_picker_at_a_landfill 0.000
## Nature_of_workwaste_picker_working_for_an_aggregator 0.223
## Nature_of_workwastepicker_working_at_mrf 0.000
## children_14 0.000
## adults_15_60 0.007
##
## $ME.INR_2251_INR_5000
## effect error t.value
## Total_Family_Members -0.041 0.006 -6.900
## Nature_of_workitinerant_waste_picker 0.065 0.011 5.758
## Nature_of_workmunicipal_contractor_collector -0.059 0.012 -5.099
## Nature_of_workothers -0.089 0.013 -6.909
## Nature_of_workstreet_sweeper -0.129 0.008 -16.187
## Nature_of_workwaste_picker_at_a_landfill 0.159 0.013 12.625
## Nature_of_workwaste_picker_working_for_an_aggregator 0.016 0.013 1.251
## Nature_of_workwastepicker_working_at_mrf -0.048 0.010 -4.684
## children_14 0.034 0.006 5.334
## adults_15_60 -0.017 0.006 -2.724
## p.value
## Total_Family_Members 0.000
## Nature_of_workitinerant_waste_picker 0.000
## Nature_of_workmunicipal_contractor_collector 0.000
## Nature_of_workothers 0.000
## Nature_of_workstreet_sweeper 0.000
## Nature_of_workwaste_picker_at_a_landfill 0.000
## Nature_of_workwaste_picker_working_for_an_aggregator 0.211
## Nature_of_workwastepicker_working_at_mrf 0.000
## children_14 0.000
## adults_15_60 0.006
##
## $ME.INR_5001_INR_10000
## effect error t.value
## Total_Family_Members -0.005 0.001 -3.464
## Nature_of_workitinerant_waste_picker -0.003 0.003 -1.087
## Nature_of_workmunicipal_contractor_collector -0.026 0.010 -2.683
## Nature_of_workothers -0.062 0.019 -3.222
## Nature_of_workstreet_sweeper -0.073 0.009 -7.841
## Nature_of_workwaste_picker_at_a_landfill -0.058 0.010 -5.729
## Nature_of_workwaste_picker_working_for_an_aggregator 0.001 0.001 1.356
## Nature_of_workwastepicker_working_at_mrf -0.015 0.006 -2.651
## children_14 0.004 0.001 3.182
## adults_15_60 -0.002 0.001 -2.218
## p.value
## Total_Family_Members 0.001
## Nature_of_workitinerant_waste_picker 0.277
## Nature_of_workmunicipal_contractor_collector 0.007
## Nature_of_workothers 0.001
## Nature_of_workstreet_sweeper 0.000
## Nature_of_workwaste_picker_at_a_landfill 0.000
## Nature_of_workwaste_picker_working_for_an_aggregator 0.175
## Nature_of_workwastepicker_working_at_mrf 0.008
## children_14 0.001
## adults_15_60 0.027
##
## $ME.INR_10001_INR_20000
## effect error t.value
## Total_Family_Members 0.051 0.007 6.943
## Nature_of_workitinerant_waste_picker -0.073 0.012 -6.267
## Nature_of_workmunicipal_contractor_collector 0.087 0.020 4.348
## Nature_of_workothers 0.144 0.027 5.329
## Nature_of_workstreet_sweeper 0.198 0.015 13.593
## Nature_of_workwaste_picker_at_a_landfill -0.150 0.009 -15.868
## Nature_of_workwaste_picker_working_for_an_aggregator -0.019 0.015 -1.299
## Nature_of_workwastepicker_working_at_mrf 0.066 0.016 4.217
## children_14 -0.042 0.008 -5.345
## adults_15_60 0.021 0.008 2.719
## p.value
## Total_Family_Members 0.000
## Nature_of_workitinerant_waste_picker 0.000
## Nature_of_workmunicipal_contractor_collector 0.000
## Nature_of_workothers 0.000
## Nature_of_workstreet_sweeper 0.000
## Nature_of_workwaste_picker_at_a_landfill 0.000
## Nature_of_workwaste_picker_working_for_an_aggregator 0.194
## Nature_of_workwastepicker_working_at_mrf 0.000
## children_14 0.000
## adults_15_60 0.007
##
## $ME.less_than_INR_20000
## effect error t.value
## Total_Family_Members 0.009 0.001 6.637
## Nature_of_workitinerant_waste_picker -0.012 0.002 -6.245
## Nature_of_workmunicipal_contractor_collector 0.017 0.005 3.697
## Nature_of_workothers 0.033 0.008 3.936
## Nature_of_workstreet_sweeper 0.044 0.005 9.604
## Nature_of_workwaste_picker_at_a_landfill -0.022 0.002 -13.402
## Nature_of_workwaste_picker_working_for_an_aggregator -0.003 0.002 -1.329
## Nature_of_workwastepicker_working_at_mrf 0.012 0.003 3.788
## children_14 -0.007 0.001 -5.204
## adults_15_60 0.004 0.001 2.708
## p.value
## Total_Family_Members 0.000
## Nature_of_workitinerant_waste_picker 0.000
## Nature_of_workmunicipal_contractor_collector 0.000
## Nature_of_workothers 0.000
## Nature_of_workstreet_sweeper 0.000
## Nature_of_workwaste_picker_at_a_landfill 0.000
## Nature_of_workwaste_picker_working_for_an_aggregator 0.184
## Nature_of_workwastepicker_working_at_mrf 0.000
## children_14 0.000
## adults_15_60 0.007
##
## $ME.all
## effect.less_than_INR_2250
## Total_Family_Members -0.014
## Nature_of_workitinerant_waste_picker 0.023
## Nature_of_workmunicipal_contractor_collector -0.018
## Nature_of_workothers -0.026
## Nature_of_workstreet_sweeper -0.039
## Nature_of_workwaste_picker_at_a_landfill 0.072
## Nature_of_workwaste_picker_working_for_an_aggregator 0.006
## Nature_of_workwastepicker_working_at_mrf -0.015
## children_14 0.011
## adults_15_60 -0.006
## effect.INR_2251_INR_5000
## Total_Family_Members -0.041
## Nature_of_workitinerant_waste_picker 0.065
## Nature_of_workmunicipal_contractor_collector -0.059
## Nature_of_workothers -0.089
## Nature_of_workstreet_sweeper -0.129
## Nature_of_workwaste_picker_at_a_landfill 0.159
## Nature_of_workwaste_picker_working_for_an_aggregator 0.016
## Nature_of_workwastepicker_working_at_mrf -0.048
## children_14 0.034
## adults_15_60 -0.017
## effect.INR_5001_INR_10000
## Total_Family_Members -0.005
## Nature_of_workitinerant_waste_picker -0.003
## Nature_of_workmunicipal_contractor_collector -0.026
## Nature_of_workothers -0.062
## Nature_of_workstreet_sweeper -0.073
## Nature_of_workwaste_picker_at_a_landfill -0.058
## Nature_of_workwaste_picker_working_for_an_aggregator 0.001
## Nature_of_workwastepicker_working_at_mrf -0.015
## children_14 0.004
## adults_15_60 -0.002
## effect.INR_10001_INR_20000
## Total_Family_Members 0.051
## Nature_of_workitinerant_waste_picker -0.073
## Nature_of_workmunicipal_contractor_collector 0.087
## Nature_of_workothers 0.144
## Nature_of_workstreet_sweeper 0.198
## Nature_of_workwaste_picker_at_a_landfill -0.150
## Nature_of_workwaste_picker_working_for_an_aggregator -0.019
## Nature_of_workwastepicker_working_at_mrf 0.066
## children_14 -0.042
## adults_15_60 0.021
## effect.less_than_INR_20000
## Total_Family_Members 0.009
## Nature_of_workitinerant_waste_picker -0.012
## Nature_of_workmunicipal_contractor_collector 0.017
## Nature_of_workothers 0.033
## Nature_of_workstreet_sweeper 0.044
## Nature_of_workwaste_picker_at_a_landfill -0.022
## Nature_of_workwaste_picker_working_for_an_aggregator -0.003
## Nature_of_workwastepicker_working_at_mrf 0.012
## children_14 -0.007
## adults_15_60 0.004
#ologit <- lrm(Income ~ Total_Family_Members + children_14 + adults_15_60 + Nature_of_work, data = data)
#print(ologit)
#d <- datadist(ologit)
#options(datadist = "d")
#summary(ologit)
#Logistic Regression
#####################################
library(aod)
## Warning: package 'aod' was built under R version 4.0.3
##
## Attaching package: 'aod'
## The following object is masked from 'package:survival':
##
## rats
data <- data %>% mutate(chronic_diseases = as.factor(chronic_diseases))
lr <- glm(formula = chronic_diseases ~ cooking_fuel, data = data, family = "binomial")
summary(lr)
##
## Call:
## glm(formula = chronic_diseases ~ cooking_fuel, family = "binomial",
## data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.3381 -0.2711 -0.1859 -0.1859 2.9604
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -4.0496 0.1149 -35.236 < 2e-16 ***
## cooking_fueldo_not_cook_at_home 1.2164 0.7366 1.651 0.0987 .
## cooking_fuellpg 0.7643 0.1403 5.446 5.15e-08 ***
## cooking_fuelothers -0.3198 1.0118 -0.316 0.7519
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 2215.7 on 9045 degrees of freedom
## Residual deviance: 2182.4 on 9042 degrees of freedom
## AIC: 2190.4
##
## Number of Fisher Scoring iterations: 6
tab_model(lr)
| chronic_diseases | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 0.02 | 0.01 – 0.02 | <0.001 |
|
cooking_fuel [do_not_cook_at_home] |
3.38 | 0.54 – 11.36 | 0.099 |
| cooking_fuel [lpg] | 2.15 | 1.64 – 2.84 | <0.001 |
| cooking_fuel [others] | 0.73 | 0.04 – 3.34 | 0.752 |
| Observations | 9046 | ||
| R2 Tjur | 0.004 | ||
o <- outreg(lr, pv = TRUE, tv = TRUE, starred = 'se')
View(o)
ltable <- coef(summary(lr))
ltable
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -4.0496369 0.1149294 -35.2358693 5.647661e-272
## cooking_fueldo_not_cook_at_home 1.2164236 0.7366278 1.6513408 9.866901e-02
## cooking_fuellpg 0.7642713 0.1403306 5.4462198 5.145154e-08
## cooking_fuelothers -0.3198088 1.0118263 -0.3160708 7.519487e-01
#R square is low,, the model is not strong. We drop this analysis.
# not significant results, no inference drawn. Drop the hypothesis
data <- data %>% mutate(Education = as.factor(Education))
data <- data %>% mutate(Gender = as.factor(Gender))
data <- data %>% mutate(Marital_Status = as.factor(Marital_Status))
data <- data %>% mutate(Category = as.factor(Category))
data <- data %>% mutate(Bank_Account = as.factor(Bank_Account))
#Mobile, ATM, digital
lr <- glm(formula = Bank_Account ~ Gender + Education + City, data = data, family = "binomial")
summary(lr)
##
## Call:
## glm(formula = Bank_Account ~ Gender + Education + City, family = "binomial",
## data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.8298 -1.0525 0.4522 0.9466 2.0969
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 2.07775 0.45997 4.517 6.27e-06 ***
## Gendergender_diverse -2.23317 1.02118 -2.187 0.028754 *
## Gendermale -0.71046 0.05427 -13.092 < 2e-16 ***
## Educationhigh_school -0.64354 0.52074 -1.236 0.216526
## Educationilliterate -1.94002 0.45022 -4.309 1.64e-05 ***
## Educationliterate_below_primary -1.57834 0.45615 -3.460 0.000540 ***
## Educationprimary -1.24000 0.45641 -2.717 0.006591 **
## Educationsecondary -0.81115 0.46892 -1.730 0.083659 .
## Educationupper_primary -1.12779 0.45834 -2.461 0.013870 *
## CityPuri 2.09127 0.16954 12.335 < 2e-16 ***
## CityCuttuck 2.61820 0.20104 13.024 < 2e-16 ***
## CityPanji -0.16877 0.14634 -1.153 0.248790
## CityPatna 0.27169 0.10940 2.483 0.013010 *
## CityBhubaneshwar 2.33397 0.20016 11.660 < 2e-16 ***
## CityGhaziabad 0.81222 0.16446 4.939 7.86e-07 ***
## CityAurangabad 1.73177 0.16679 10.383 < 2e-16 ***
## CityJammu 1.95569 0.16735 11.686 < 2e-16 ***
## CityRishikesh 1.45290 0.16291 8.919 < 2e-16 ***
## CityChennai 0.31389 0.13114 2.394 0.016686 *
## CityJaipur 0.25101 0.12973 1.935 0.053004 .
## CityMumbai 0.01447 0.11074 0.131 0.896054
## CityDelhi_Cant 2.23235 0.16876 13.228 < 2e-16 ***
## CityVaranasi 0.44386 0.11855 3.744 0.000181 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 11294.5 on 9045 degrees of freedom
## Residual deviance: 9593.4 on 9023 degrees of freedom
## AIC: 9639.4
##
## Number of Fisher Scoring iterations: 5
tab_model(lr)
| Bank_Account | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 7.99 | 3.48 – 21.74 | <0.001 |
| Gender [gender_diverse] | 0.11 | 0.02 – 1.11 | 0.029 |
| Gender [male] | 0.49 | 0.44 – 0.55 | <0.001 |
| Education [high_school] | 0.53 | 0.18 – 1.39 | 0.217 |
| Education [illiterate] | 0.14 | 0.05 – 0.32 | <0.001 |
|
Education [literate_below_primary] |
0.21 | 0.08 – 0.47 | 0.001 |
| Education [primary] | 0.29 | 0.11 – 0.66 | 0.007 |
| Education [secondary] | 0.44 | 0.16 – 1.04 | 0.084 |
| Education [upper_primary] | 0.32 | 0.12 – 0.74 | 0.014 |
| City [Puri] | 8.10 | 5.85 – 11.37 | <0.001 |
| City [Cuttuck] | 13.71 | 9.36 – 20.64 | <0.001 |
| City [Panji] | 0.84 | 0.63 – 1.13 | 0.249 |
| City [Patna] | 1.31 | 1.06 – 1.63 | 0.013 |
| City [Bhubaneshwar] | 10.32 | 7.05 – 15.47 | <0.001 |
| City [Ghaziabad] | 2.25 | 1.64 – 3.12 | <0.001 |
| City [Aurangabad] | 5.65 | 4.10 – 7.88 | <0.001 |
| City [Jammu] | 7.07 | 5.12 – 9.88 | <0.001 |
| City [Rishikesh] | 4.28 | 3.12 – 5.91 | <0.001 |
| City [Chennai] | 1.37 | 1.06 – 1.77 | 0.017 |
| City [Jaipur] | 1.29 | 1.00 – 1.66 | 0.053 |
| City [Mumbai] | 1.01 | 0.82 – 1.26 | 0.896 |
| City [Delhi_Cant] | 9.32 | 6.74 – 13.07 | <0.001 |
| City [Varanasi] | 1.56 | 1.24 – 1.97 | <0.001 |
| Observations | 9046 | ||
| R2 Tjur | 0.172 | ||
o <- outreg(lr, pv = TRUE, tv = TRUE, starred = 'se')
#View(o)
data <- data %>% mutate(ration_card = as.factor(ration_card))
lr1 <- glm(formula = ration_card ~ Gender + City, data = data, family = "binomial")
summary(lr1)
##
## Call:
## glm(formula = ration_card ~ Gender + City, family = "binomial",
## data = data)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.0248 -1.0041 0.6828 0.8591 1.8162
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.332828 0.108347 12.301 < 2e-16 ***
## Gendergender_diverse 0.727841 1.083663 0.672 0.501807
## Gendermale -0.407144 0.050346 -8.087 6.12e-16 ***
## CityPuri 0.004719 0.141806 0.033 0.973452
## CityCuttuck -0.263166 0.140331 -1.875 0.060748 .
## CityPanji -2.052955 0.158828 -12.926 < 2e-16 ***
## CityPatna -1.755222 0.118908 -14.761 < 2e-16 ***
## CityBhubaneshwar 0.579131 0.163026 3.552 0.000382 ***
## CityGhaziabad -1.132245 0.158648 -7.137 9.55e-13 ***
## CityAurangabad -1.197709 0.139753 -8.570 < 2e-16 ***
## CityJammu 0.232898 0.148153 1.572 0.115949
## CityRishikesh 0.140864 0.156416 0.901 0.367815
## CityChennai -0.710661 0.137842 -5.156 2.53e-07 ***
## CityJaipur -1.592378 0.137507 -11.580 < 2e-16 ***
## CityMumbai -0.302892 0.121319 -2.497 0.012537 *
## CityDelhi_Cant -2.361635 0.149696 -15.776 < 2e-16 ***
## CityVaranasi -0.526191 0.127133 -4.139 3.49e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 12254 on 9045 degrees of freedom
## Residual deviance: 10795 on 9029 degrees of freedom
## AIC: 10829
##
## Number of Fisher Scoring iterations: 4
tab_model(lr1)
| ration_card | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 3.79 | 3.08 – 4.70 | <0.001 |
| Gender [gender_diverse] | 2.07 | 0.35 – 39.25 | 0.502 |
| Gender [male] | 0.67 | 0.60 – 0.73 | <0.001 |
| City [Puri] | 1.00 | 0.76 – 1.33 | 0.973 |
| City [Cuttuck] | 0.77 | 0.58 – 1.01 | 0.061 |
| City [Panji] | 0.13 | 0.09 – 0.17 | <0.001 |
| City [Patna] | 0.17 | 0.14 – 0.22 | <0.001 |
| City [Bhubaneshwar] | 1.78 | 1.30 – 2.46 | <0.001 |
| City [Ghaziabad] | 0.32 | 0.24 – 0.44 | <0.001 |
| City [Aurangabad] | 0.30 | 0.23 – 0.40 | <0.001 |
| City [Jammu] | 1.26 | 0.94 – 1.69 | 0.116 |
| City [Rishikesh] | 1.15 | 0.85 – 1.57 | 0.368 |
| City [Chennai] | 0.49 | 0.37 – 0.64 | <0.001 |
| City [Jaipur] | 0.20 | 0.16 – 0.27 | <0.001 |
| City [Mumbai] | 0.74 | 0.58 – 0.94 | 0.013 |
| City [Delhi_Cant] | 0.09 | 0.07 – 0.13 | <0.001 |
| City [Varanasi] | 0.59 | 0.46 – 0.76 | <0.001 |
| Observations | 9046 | ||
| R2 Tjur | 0.156 | ||
#View(paletteer::palettes_d_names)
ggpiestats(data, City, package = "ggsci", palette = "default_igv")
ggpiestats(data, Gender)
ggpiestats(data, Income)
#ggstatsplot::ggbarstats(data, Category)
#one way anova
#########################################################
#ggbetweenstats(data, x = Gender, y = Bank_Account)
#rlang::last_error()
#lin <- lm(formula = prc_loss ~ MW_left_covid + Age + Sector_Company + Type_Company, data = data)
#summary(lin)
#ANOVA
#two.way <- aov(prc_loss ~ MW_left_covid + Sector_Company + Type_Company, data = data)
#outreg(two.way)
#t <- summary(two.way)
#tab_model(t)
#plot(two.way)
#tukey.two.way<-TukeyHSD(two.way)
#table(tukey.two.way)
child <- read_excel("C:/Users/ramya.emandi/Desktop/2nd yr UNDP/Proj Utthaan/Baseline/Rawdata_with groups_2021-03-23.xlsx", sheet = "child")
View(child)
ggpiestats(child, Gender_child)
ggpiestats(child, going_to_school)
ggpiestats(child, type_of_education)
ggpiestats(child, why_no_school, package = "awtools", palette = "bpalette")
#LR
child <- child %>% mutate(going_to_school = as.factor(going_to_school))
child <- child %>% mutate(Gender_child = as.factor(Gender_child))
child <- child %>% mutate(type_of_education = as.factor(type_of_education))
lr_child <- glm(formula = going_to_school ~ Gender_child, data = child, family = "binomial")
summary(lr_child)
##
## Call:
## glm(formula = going_to_school ~ Gender_child, family = "binomial",
## data = child)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.274 -1.251 1.084 1.106 1.106
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.22323 0.02803 7.964 1.66e-15 ***
## Gender_childmale -0.05185 0.03915 -1.324 0.185
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 14521 on 10547 degrees of freedom
## Residual deviance: 14519 on 10546 degrees of freedom
## AIC: 14523
##
## Number of Fisher Scoring iterations: 3
tab_model(lr_child)
## Profiled confidence intervals may take longer time to compute. Use 'df_method="wald"' for faster computation of CIs.
| going_to_school | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 1.25 | 1.18 – 1.32 | <0.001 |
| Gender_child [male] | 0.95 | 0.88 – 1.03 | 0.185 |
| Observations | 10548 | ||
| R2 Tjur | 0.000 | ||
o_child <- outreg(lr_child, pv = TRUE, tv = TRUE, starred = 'se')
# not significant results, no inference drawn. Drop the hypothesis
#R square is low,, the model is not strong. We drop this analysis. Can say that, irrespective of gender, the children are sent to school
lr_child <- glm(formula = type_of_education ~ Gender_child, data = child, family = "quasibinomial")
summary(lr_child)
##
## Call:
## glm(formula = type_of_education ~ Gender_child, family = "quasibinomial",
## data = child)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -3.9900 0.0264 0.0453 0.0453 0.0453
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.960 1.000 7.957 2.1e-15 ***
## Gender_childmale -1.078 1.155 -0.933 0.351
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for quasibinomial family taken to be 1.000473)
##
## Null deviance: 66.219 on 5790 degrees of freedom
## Residual deviance: 65.215 on 5789 degrees of freedom
## (4757 observations deleted due to missingness)
## AIC: NA
##
## Number of Fisher Scoring iterations: 10
tab_model(lr_child)
| type_of_education | |||
|---|---|---|---|
| Predictors | Odds Ratios | CI | p |
| (Intercept) | 2863.00 | 650.31 – 50257.52 | <0.001 |
| Gender_child [male] | 0.34 | 0.02 – 2.66 | 0.351 |
| Observations | 5791 | ||
| R2 Tjur | 0.000 | ||
o_child <- outreg(lr_child, pv = TRUE, tv = TRUE, starred = 'se')
#same result
senior <- read_excel("C:/Users/ramya.emandi/Desktop/2nd yr UNDP/Proj Utthaan/Baseline/Rawdata_with groups_2021-03-23.xlsx", sheet = "Senior_contribution")
View(senior)
ggpiestats(senior, Gender_senior_citizen)
ggpiestats(senior, Contributing_to_family_income_senior_citizen)
adult <- read_excel("C:/Users/ramya.emandi/Desktop/2nd yr UNDP/Proj Utthaan/Baseline/Rawdata_with groups_2021-03-23.xlsx", sheet = "Adult_contribution")
View(adult)
ggpiestats(adult, Gender_adult)
ggpiestats(adult, Contributing_to_family_income_adult)
author: “Ramya Emandi” date: “26/02/2021”