The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » India » k fold cross validation for logistic regression in R (stuck up using cross validation using surveyCV package)
Re: k fold cross validation for logistic regression in R [message #26502 is a reply to message #26409] Mon, 27 March 2023 08:05 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3199
Registered: February 2013
Senior Member
Following is a response from DHS Senior Analysis & Research Manager, Shireen Assaf:

# install and load the packages you need
install.packages("survey")
library(survey)

# setting your survey design
# To identify the survey design, you need three variables: weight, psu, and strata

# creating the sampling weight variable. 
IRdata$wt <- IRdata$v005/1000000

mysurvey<-svydesign(id=IRdata$v021, data=IRdata, strata=IRdata$v022,  weight=IRdata$wt, nest=T)
options(survey.lonely.psu="adjust")

#now you can use the svy commands in the survey package and use the "mysurvey" sample design object. Check the commands you can use in the survey package. 

# for example

# table of variable v313 (FP use) this is after you attach your data. You can also use svyby, svyglm, etc. 

svytable(~v313, mysurvey)


[Updated on: Mon, 27 March 2023 08:05]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Fertility preference (table 4.19.1)
Next Topic: Norms variables [[URGENT]]
Goto Forum:
  


Current Time: Tue Nov 26 21:36:05 Coordinated Universal Time 2024