Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zelig-normal-survey incorrectly passes the weights to both svydesign and svyglm #332

Open
chiungming opened this issue May 30, 2019 · 0 comments

Comments

@chiungming
Copy link

For some reason Zelig passes the weights to both svydesign and svyglm. Is there a way to prevent Zelig from passing the weights to svyglm?

data(api)

zelig(meals ~ yr.rnd, model = "normal.survey", id = ~dnum, weights = ~api00, data = apiclus1) 

## Warning: Not all features are available in Zelig Survey.
## Consider using surveyglm and setx directly.
## For details see: <http://docs.zeligproject.org/articles/to_zelig.html>.

## How to cite this model in Zelig:
##   Nicholas Carnes. 2019.
##   normal-survey: Normal Regression for Continuous Dependent Variables with Survey Weights
##   in Christine Choirat, Christopher Gandrud, James Honaker, Kosuke Imai, Gary King, and Olivia Lau,
##   "Zelig: Everyone's Statistical Software," http://zeligproject.org/

## Model: 
## 
## Call:
## z5$zelig(formula = meals ~ yr.rnd, data = apiclus1, ids = ~dnum, 
##     weights = ~api00)
## 
## Survey design:
## survey::svydesign(data = data, ids = ids, probs = probs, strata = strata, 
##     fpc = fpc, nest = nest, check.strata = check.strata, weights = localWeights)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)   41.949      4.854   8.642 9.51e-07
## yr.rndYes     38.622      4.411   8.755 8.22e-07
## 
## (Dispersion parameter for gaussian family taken to be 381405.3)
## 
## Number of Fisher Scoring iterations: 2
## 
## Next step: Use 'setx' method

api_design <- svydesign(id = ~dnum, weights = ~api00, data = apiclus1)

svyglm(meals ~ yr.rnd, api_design, family = gaussian("identity"), weights = api00) %>% 
summary()

## 
## Call:
## svyglm(formula = meals ~ yr.rnd, design = api_design, family = gaussian("identity"), 
##     weights = api00)
## 
## Survey design:
## svydesign(id = ~dnum, weights = ~api00, data = apiclus1)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   41.949      4.854   8.642 9.51e-07 ***
## yr.rndYes     38.622      4.411   8.755 8.22e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 381405.3)
## 
## Number of Fisher Scoring iterations: 2

svyglm(meals ~ yr.rnd, api_design, family = gaussian("identity")) %>% summary()

## 
## Call:
## svyglm(formula = meals ~ yr.rnd, design = api_design, family = gaussian("identity"))
## 
## Survey design:
## svydesign(id = ~dnum, weights = ~api00, data = apiclus1)
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   45.267      5.262   8.603 1.00e-06 ***
## yr.rndYes     36.649      4.577   8.007 2.21e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 621.4498)
## 
## Number of Fisher Scoring iterations: 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant