R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

importing data and weighting

dtat=dta%>%
  select("hhid" ,"hvidx","hv000","hv001","hv002" ,"hv003","hv005","hv011", "hv012", "hv021","hv023" ,"hv024", "hv025" ,"hv104"  , "hv105" , "hv102","hv106","hv270" , "hv271" ,  "hv270a", "hv271a", "sh73","sh74a","sh74b", "sh74c" ,"sh74d" ,"sh74e" ,"sh74x", wt )

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

selecting only dejure members

Survey design# Not sure if the weights will work as they are not divded by 1000000

survey_design0=as_survey_design (
  .data= dtat1,
  ids = "hv001",
  strata = "hv023",
  weights = wt
)
options(survey.lonely.psu = "adjust")

Recode:

survey_design0<- survey_design0%>% mutate(
  residence = factor(hv025,
                      levels = c(1, 2),
                      labels = c("Urban",
                                 "Rural"))) 

  survey_design0<- survey_design0 %>% mutate(
    sex=factor(hv104,
             levels= c(1,2,9),
             labels= c("Male",
                      "Female",
                      "Missing")))
  survey_design0<- survey_design0%>% mutate(
    Education =factor(hv106,
             levels= c(0,1,2,3,8,9),
             labels= c("No education, preschool",
                      "Primary",
                      "Secondary",
                      "Higher",
                      "Don't Know",
                      "Missing")))
   survey_design0<- survey_design0%>% mutate(
    Wealth =factor(hv270a,
             levels= c(1,2,3,4,5),
             labels= c("Poorest",
                      "Poorer",
                      "Middle",
                      "Richer",
                      "Richest")))
   
   survey_design0 <-survey_design0%>% mutate(
     State=factor(hv024,
                  levels=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,34,35,36,37),
    labels=c("jammu & kashmir",
             "himachal pradesh ",
             " punjab",
             "chandigarh",
             "uttarakhand",
              "haryana ",
             " nct of delhi",
             "rajasthan ",
             "uttar pradesh ",
             " bihar ",
              " sikkim ",
             "arunachal pradesh ",
             " nagaland ",
             "manipur ",
             " mizoram " ,
             " tripura ",
             "meghalaya ",
             "assam ",
             "west bengal",
             "jharkhand ",
             "odisha",
             "chhattisgarh ",
             "madhya pradesh ",
            " gujarat ",
            "dadra & nagar haveli and daman & diu ",
            "maharashtra",
            "andhra pradesh ",
            " karnataka ",
            "  goa ",
            "lakshadweep",
            " kerala",
            " tamil nadu",
            "puducherry ",
            "andaman & nicobar islands",
            " telangana ",
            "  ladakh " )))
   
   
   survey_design0<- survey_design0%>% mutate(
  use_publicfacility = factor(sh73,
                      levels = c(11, 112,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,31,41,42,43,44,45,46,47,48,49,50,51,52,53,54,61,62,96),
                      labels = c("public: government / municipal hospital",
                                 "public: government dispensary",
                                 " public: uhc / uhp / ufwc",
                                 "public: chc / rural hospital / block phc ",
                                 "public: phc / additional phc ",
                                 "public: sub-centre ",
                                 "public ayush: ayurveda ",
                                 "public ayush: yoga and naturopathy ",
                                 "public ayush: unani ",
                                 "public ayush: siddha ",
                                 "public ayush: homeopathy ",
                                 " public ayush: sowa rigpa (ttm) ",
                                 "public ayush: other ",
                                 "public: anganwadi/icds centre ",
                                 " public: asha ",
                                 " public: government mobile clinic ",
                                 "other public sector ",
                                 "ngo or trust hospital / clinic",
                                 "private hospital ",
                                 " private doctor / clinic ",
                                 "private paramedic",
                                 "private ayush: ayurveda ",
                                 "private ayush: yoga and naturopathy ",
                                 "private ayush: unani ",
                                 "private ayush: siddha ",
                                 "private ayush: homeopathy ",
                                 "private ayush: sowa rigpa (ttm) ",
                                 "private ayush: other ",
                                 "private: traditional healer ",
                                 "private: pharmacy / drugstore ",
                                 "private: dai (tba) ",
                                 "private: dai (tba) ",
                                 "shop ",
                                 "home treatment ",
                                 "other "))) 
   
   survey_design0<- survey_design0 %>% mutate(
  nonearby_facility = factor(sh74a,
                      levels = c(0, 1),
                      labels = c("No",
                                 "Yes"
                                 ))) 
   
   survey_design0<- survey_design0%>% mutate(
timing_notconvenient = factor(sh74b,
                      levels = c(0, 1),
                      labels = c("No",
                                 "Yes"))) 
   
  survey_design0<- survey_design0%>% mutate(
healthpersonel_absent = factor(sh74c,
                      levels = c(0, 1),
                      labels = c("No",
                                 "Yes"))) 
  
  survey_design0<- survey_design0%>% mutate(
        toolong_waitingtime= factor(sh74d,
                      levels = c(0, 1),
                      labels = c("No",
                                 "Yes"))) 
  
  survey_design0<- survey_design0%>% mutate(
  poor_quality = factor(sh74e,
                      levels = c(0, 1),
                      labels = c("No",
                                 "Yes"))) 
  survey_design0<- survey_design0%>% mutate(
  other = factor(sh74x,
                      levels = c(0, 1),
                      labels = c("No",
                                 "Yes"))) 
  
  #survey_design0<- survey_design0 %>% mutate (
  #donotuse_ghf=factor(donotuse_ghf,
                      #levels=c(0,1),
                      #labels=c("No","Yes")))

Check

View (survey_design0)
survey_design0 %>%
  filter(!is.na(sex)) %>%
  filter(!is.na(residence)) %>%
  group_by(sex,residence) %>%
  summarise(mean = survey_mean(vartype = "ci"))
survey_design0 %>%
  filter(!is.na(State)) %>%
  filter(!is.na(nonearby_facility)) %>%
  group_by(State,nonearby_facility) %>%
  summarise(mean = survey_mean(vartype = "ci"))