This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Idea: use wpp2022 or wpp2024 data | |
| # 1) select year whose pop we want to adjust (2000) | |
| # 2) get mort for 10 prior years | |
| # 3) in cohort lines, get Lx, reverse-Sx, reverse cumprod of reverse-Sx | |
| # 4) inflate year 2000 pop to fill Lexis space 1990-1999 | |
| # 5) calculate exposures by age and year 1990-1999, ages 15-49 | |
| # TODO: 1. merge with asfr, get births, use to get Bt series. | |
| # 2. use same general idea to forward-survive Bt to Jan 1 2000, giving adjusted pop ages 0-9 | |
| # 3. make adjustments for mid-year census, in case given. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # note, our citation lookup needs an openalex paper id | |
| # but you probably only have the doi. This does the translation | |
| # this returns a full url, where the id is the last part | |
| get_openalex_id_from_doi <- function(doi, email) { | |
| base_url <- "https://api.openalex.org/works/doi:" | |
| doi_encoded <- URLencode(doi, reserved = TRUE) | |
| url <- paste0(base_url, doi_encoded, "?mailto=",email) | |
| res <- httr::GET(url, httr::user_agent(email)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # See also https://gist.github.com/timriffe/f820143e939f9262b3083122e1ce49ae | |
| # for semantic scholar. Sorry output isn't harmonized | |
| get_citing_papers_opencite <- function(doi){ | |
| openciteurl <- paste0( "https://opencitations.net/index/coci/api/v1/citations/",doi ) | |
| result <- rjson::fromJSON(file = openciteurl) | |
| result |> lapply(as_tibble) |> bind_rows() | |
| } | |
| get_second_order_citations_opencite <- function(doi){ | |
| citing <- get_citing_papers_opencite(doi) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # get the semantic scholar method | |
| library(httr) | |
| library(jsonlite) | |
| library(dplyr) | |
| get_citing_papers <- function(doi, page_size = 100, max_results = 10000) { | |
| base_url <- paste0("https://api.semanticscholar.org/graph/v1/paper/DOI:", | |
| URLencode(doi, reserved = TRUE), | |
| "/citations") | |
| fields <- "citingPaper.paperId,citingPaper.title,citingPaper.citationCount" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # download Excel from here: | |
| # https://docs.google.com/spreadsheets/d/1zJPZ9uu6NpYruV8utJ-Cby4BGMpHw4XE/edit?usp=sharing&ouid=107044799582363262397&rtpof=true&sd=true | |
| library(tidyverse) | |
| library(readxl) | |
| library(colorspace) | |
| dat <- read_excel("Data/graficos_prev_ratio_antia_yolanda.xlsx", sheet = "table") | |
| p <- | |
| dat %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(scholar) | |
| library(googlesheets4) | |
| library(tidyverse) | |
| gs4_auth(email = "[email protected]") | |
| authors <- read_sheet(ss = "https://docs.google.com/spreadsheets/d/18RWKaMvkUOGp_URLwRu-3jTLUz2iI4y3oN_hu8MLoRg/edit#gid=0") | |
| authors | |
| pubsi <- list() | |
| for (i in 1:nrow(authors)){ | |
| pubsi[[i]] <- get_publications(id = authors$scholar_id[i], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(rvest) | |
| library(httr) | |
| options(timeout = 1e6) | |
| cdc_url <- "https://www.cdc.gov/nchs/data_access/vitalstatsonline.htm" | |
| pg <- read_html(cdc_url) | |
| test <- html_attr(html_nodes(pg, "a"), "href") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(HMDHFDplus) | |
| library(tidyverse) | |
| library(data.table) | |
| # read and reshape births by year, age, order | |
| Bxi <- readHFDweb("SWE","birthsRRbo", | |
| username = Sys.getenv("us"), | |
| password = Sys.getenv("pw"))|> | |
| select(-OpenInterval, -Total) |> | |
| pivot_longer(B1:B5p, names_to = "order", values_to = "Bxi") |> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(HMDHFDplus) | |
| fert <- readHFDweb("USA", | |
| "asfrRR", | |
| username = Sys.getenv("us"), | |
| password = Sys.getenv("pw")) | |
| # ASFR as function of rates: | |
| # decomposition result is just the age-specific rate differences | |
| fert |> |
NewerOlder