writing a function using svyglm command


I am trying to write a function using svyglm and I am stuck. I am using Demographic Health Survey data , now applying Nepal dataset. From Nepal data, I made it 6 dataframes according to the domain specific titles such as sociodemographic, disease severity etc.
Now I want to run uni-variate analysis for each variable within each dataframe. The following are my codes.
If I write it just for one variable, it works.
outcome<- NPfever$fevercog_ab_01
DHSdesign<- svydesign(id = ~v021, strata = ~v023, weights = ~wgt,
data = NPfever)
output<- svyglm(outcome ~ momage_01, family= "binomial", design = DHSdesign )

But I want to write it for all variables in each dataframe. I have written something like this.

uni_model<- function(x){
DHSdesign<- svydesign(id = ~v021, strata = ~v023, weights = ~wgt,
data = NPfever)
output<- svyglm(outcome ~ x, family= "binomial", design = DHSdesign )
outcome<- NPfever$fevercog_ab_01

When I apply my function, then got an error.
basic_var_mod<- map(basic_var,uni_model)

basic_var is one dataframe I have created and it includes some basic demographic variables. I still want to use survey design specification from NPfever dataframe but run svyglm with variables from each dataframe.

Could somebody enlighten me how to proceed? If you need further info, kindly let me know.
Thank you so much in advance.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.