{"id":16703776,"url":"https://github.com/leeper/gk2011","last_synced_at":"2025-05-16T18:34:35.864Z","repository":{"id":56937680,"uuid":"59699871","full_name":"leeper/GK2011","owner":"leeper","description":"Gaines and Kuklinski (2011) Estimators for Hybrid Experiments","archived":false,"fork":false,"pushed_at":"2018-04-22T08:14:00.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-13T17:53:50.792Z","etag":null,"topics":["cran","experiment","r","rct","self-selection","treatment-effects"],"latest_commit_sha":null,"homepage":"https://cloud.r-project.org/package=GK2011","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leeper.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-25T21:45:10.000Z","updated_at":"2021-05-27T18:05:16.000Z","dependencies_parsed_at":"2022-08-21T01:00:10.760Z","dependency_job_id":null,"html_url":"https://github.com/leeper/GK2011","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2FGK2011","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2FGK2011/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2FGK2011/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leeper%2FGK2011/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leeper","download_url":"https://codeload.github.com/leeper/GK2011/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225444701,"owners_count":17475353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cran","experiment","r","rct","self-selection","treatment-effects"],"created_at":"2024-10-12T19:09:30.784Z","updated_at":"2024-11-19T23:52:37.645Z","avatar_url":"https://github.com/leeper.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gaines and Kuklinski (2011) Estimators for Hybrid Experiments\n\n**GK2011** is a package for providing implementations of the treatment effect estimators for hybrid (self-selection) experiments, as developed by Gaines and Kuklinski (2011).\n\nThese functions estimate local average treatment effects for unobserved population subgroups inclined and disinclined to be treated, as revealed by a three-condition (two-arm) \"hybrid\" experimental design. In the design, participants are randomly assigned to one of three conditions: 1) treatment (T), 2) control (C), or 3) self-selection (S) of treatment or control. The design enables the estimation of four treatment effects:\n\n 1. The sample average treatment effect,\n 2. The effect for those inclined to choose treatment,\n 3. The effect for those disinclined to choose treatment (or, equivalent, to inclined to choose control), and\n 4. The naive difference in the outcome between those who chose treatment rather than control.\n\n\n\n## Code Examples\n\nThe only function is `estimate()`, which provides a simple interface for estimating all effects:\n\n```{r}\nlibrary(\"GK2011\")\n\n# create fake data\nset.seed(12345)\nd \u003c- \ndata.frame(rand = c(rep(1, 200), rep(0, 100)),\n           tr = c(rep(0, 100), rep(1, 100), rep(0, 37), rep(1, 63)),\n           y = c(rnorm(100), rnorm(100) + 1, rnorm(37), rnorm(63) + 3))\n\n# estimate effects\nestimate(rand = d$rand, tr = d$tr, y = d$y)\n```\n\nThe response structure is a data.frame containing the name of each effect, the effect estimate, and bootstrapped standard error.\n\n### Gaines and Kuklinski's data\n\nA small example dataset is included that contains treatment and outcome data from Gaines and Kuklinski's (2011) study. The following code replicate the main descriptive results from Table 2 of their paper:\n\n```{r}\ndata(ajps)\npmean \u003c- function(x) sprintf(\"%0.1f\", mean(x))\ncbind(\n  # Democrats\n  aggregate(cbind(therm.mccain, therm.obama) ~ tr, data = ajps[ajps$pid == 1, ], FUN = pmean)[, 1:3],\n  n_dem = aggregate(therm.obama ~ tr, data = ajps[ajps$pid == 1, ], FUN = length)[, 2],\n  # Republicans\n  aggregate(cbind(therm.mccain, therm.obama) ~ tr, data = ajps[ajps$pid == -1, ], FUN = pmean)[, 2:3],\n  n_rep = aggregate(therm.obama ~ tr, data = ajps[ajps$pid == -1, ], FUN = length)[, 2]\n)\n```\n\nThe paper reports four main sets of experimental results, separating the experiment by outcome (feeling thermometers for Obama and McCain) and by respondents' party identification (Democrats and Republicans).\n\n\nHere are effects for McCain among Democrats:\n\n```{r}\nwith(ajps[ajps$pid == 1, ], {\n  estimate(rand = tr %in% 1:2, tr = tr %in% c(1,3), y = therm.mccain)\n})\n```\n\nHere are effects for McCain among Republicans:\n\n```{r}\nwith(ajps[ajps$pid == -1, ], {\n  estimate(rand = tr %in% 1:2, tr = tr %in% c(1,3), y = therm.mccain)\n})\n```\n\nHere are effects for Obama among Democrats:\n\n```{r}\nwith(ajps[ajps$pid == 1, ], {\n  estimate(rand = tr %in% 1:2, tr = tr %in% c(1,3), y = therm.obama)\n})\n```\n\nHere are effects for Obama among Republicans:\n\n```{r}\nwith(ajps[ajps$pid == -1, ], {\n  estimate(rand = tr %in% 1:2, tr = tr %in% c(1,3), y = therm.obama)\n})\n```\n\n\n## Installation\n\n[![CRAN](https://www.r-pkg.org/badges/version/GK2011)](https://cran.r-project.org/package=GK2011)\n[![Build Status](https://travis-ci.org/leeper/GK2011.png?branch=master)](https://travis-ci.org/leeper/GK2011)\n[![codecov.io](https://codecov.io/github/leeper/GK2011/coverage.svg?branch=master)](https://codecov.io/github/leeper/GK2011?branch=master)\n\nThis package is not yet on CRAN. To install the latest development version you can pull directly from GitHub:\n\n```R\nif(!require(\"remotes\")){\n    install.packages(\"remotes\")\n}\nremotes::install_github(\"leeper/GK2011\")\n```\n\n\n## References\n\nBrian J. Gaines and James H. Kuklinski, (2011), \"Experimental Estimation of Heterogeneous Treatment Effects Related to Self-Selection,\" *American Journal of Political Science* 55(3): 724-736, doi:10.1111/j.1540-5907.2011.00518.x.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeper%2Fgk2011","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleeper%2Fgk2011","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleeper%2Fgk2011/lists"}