Comments (5)
Bootstrap sampling with complex survey weights is much more involved than with simple random sampling. I do not believe that we currently have any bootstrapping implemented for any complex survey designs. https://arxiv.org/pdf/1902.08944v1.pdf
from parameters.
We cannot simply sample from the data, we would also re-create the survey design for each bootstrap-sample, right? I think, unless we find a good solution, we should for now give an informative message that bootstrapping is not possible for models with survey design.
from parameters.
Yes, the replications or resamples would have to come out of the previously created survey design object.
Procedurally I saw it this way, although I am not sure if it was correct.
# Load necessary libraries
library(survey)
#> Loading required package: grid
#> Loading required package: Matrix
#> Loading required package: survival
#>
#> Attaching package: 'survey'
#> The following object is masked from 'package:graphics':
#>
#> dotchart
library(boot)
#>
#> Attaching package: 'boot'
#> The following object is masked from 'package:survival':
#>
#> aml
# Use the mtcars dataset
data("mtcars")
# Create a fictitious survey design (random sampling weights)
# In real survey data, weights would be based on survey methodology
mtcars$weights <- runif(nrow(mtcars))
design <- svydesign(ids = ~1, data = mtcars, weights = ~weights)
# Fit a model using svyglm
# Predicting mpg (miles per gallon) based on wt (weight of the car)
model_svy <- svyglm(mpg ~ wt, design = design)
# Define the bootstrapping function
# This function fits the model to a resampled dataset and returns the coefficients
boot_function <- function(data, indices) {
# Create a resampled dataset
resampled_data <- data[indices, ]
# Create a new survey design for the resampled data
resampled_design <- svydesign(ids = ~1, data = resampled_data, weights = ~weights)
# Fit the model to the new survey design
resampled_model <- svyglm(mpg ~ wt, design = resampled_design)
# Return the coefficients
coef(resampled_model)
}
# Perform the bootstrapping process
# R is the number of bootstrap replications
boot_results <- boot(data = mtcars, statistic = boot_function, R = 1000)
# View the results
print(boot_results)
#>
#> ORDINARY NONPARAMETRIC BOOTSTRAP
#>
#>
#> Call:
#> boot(data = mtcars, statistic = boot_function, R = 1000)
#>
#>
#> Bootstrap Statistics :
#> original bias std. error
#> t1* 37.848293 0.20758589 2.1499704
#> t2* -5.535675 -0.08357097 0.6595995
Created on 2023-11-20 with reprex v2.0.2
Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.3.0 (2023-04-21 ucrt)
#> os Windows 11 x64 (build 22621)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate Spanish_Peru.utf8
#> ctype Spanish_Peru.utf8
#> tz America/Lima
#> date 2023-11-20
#> pandoc 3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> boot * 1.3-28.1 2022-11-22 [2] CRAN (R 4.3.0)
#> cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.0)
#> DBI 1.1.3 2022-06-18 [1] CRAN (R 4.3.0)
#> digest 0.6.31 2022-12-11 [1] CRAN (R 4.3.0)
#> evaluate 0.21 2023-05-05 [1] CRAN (R 4.3.0)
#> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0)
#> fs 1.6.2 2023-04-25 [1] CRAN (R 4.3.0)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.0)
#> htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.3.0)
#> knitr 1.43 2023-05-25 [1] CRAN (R 4.3.0)
#> lattice 0.21-8 2023-04-05 [2] CRAN (R 4.3.0)
#> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.0)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0)
#> Matrix * 1.5-4 2023-04-04 [2] CRAN (R 4.3.0)
#> mitools 2.4 2019-04-26 [1] CRAN (R 4.3.0)
#> purrr 1.0.1 2023-01-10 [1] CRAN (R 4.3.0)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.0)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.0)
#> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.3.0)
#> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.3.0)
#> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.3.0)
#> rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.0)
#> rmarkdown 2.22 2023-06-01 [1] CRAN (R 4.3.0)
#> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.3.0)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0)
#> styler 1.10.1 2023-06-05 [1] CRAN (R 4.3.0)
#> survey * 4.2-1 2023-05-03 [1] CRAN (R 4.3.0)
#> survival * 3.5-5 2023-03-12 [2] CRAN (R 4.3.0)
#> vctrs 0.6.2 2023-04-19 [1] CRAN (R 4.3.0)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 4.3.0)
#> xfun 0.39 2023-04-20 [1] CRAN (R 4.3.0)
#> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.3.0)
#>
#> [1] C:/Users/brian/AppData/Local/R/win-library/4.3
#> [2] C:/Program Files/R/R-4.3.0/library
#>
#> ──────────────────────────────────────────────────────────────────────────────
from parameters.
Simply resampling cases like that won't meet regularity conditions that we need for bootstrap inference unfortunately.
This is the basic procedure for resampling the weights to use in the bootstrap from the paper I link above
We could implement this or similar procedures, but I wonder if someone has already implemented these in another package?
from parameters.
Related Issues (20)
- parameters fails with nestedLogit models HOT 7
- Issues with `parameters()` on `marginaleffects` objects HOT 2
- Plotting model_parameters() output for gam objects
- Strange behavior in standardise_parameters() HOT 3
- Random effects reporting with spaMM and CIs with lme4
- Wrong DFs in `model_parameters.fixest` HOT 20
- Calculating by-group estimates and CIs for a random intercept grouping variable in `lmer()` HOT 10
- Wrong header when using identity-link with GLMs HOT 11
- `model_parameters`: Add variables names for `chisq.test` objects
- parameters(): `performance=TRUE` arg as alias for `summary` HOT 2
- `nnet::multinom` with wide format data
- `vcov` argument not supported for `plm` models HOT 5
- `model_parameters()` on marginaleffects::predictions()-object defaults to `exponentiate = TRUE` HOT 1
- check mmrm implementation
- `print(include_reference = TRUE)` doesn't work with pipes HOT 1
- Select and list the same parameter from multiple models HOT 2
- Combine multiple imputation with robust standard errors? HOT 3
- Warn (in model_parameters) when argument is not supported by method? HOT 1
- Support for {circular} uniformity tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parameters.