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
| name: Build and Deploy | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| deploy: |
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(sf) | |
| library(ggthemes) | |
| #import des données spatiales | |
| ContoursCommunes<-st_read("https://github.com/Valexandre/france-geojson/raw/master/communes.geojson")%>%st_transform(crs = 2154) | |
| arr<-st_read("https://raw.githubusercontent.com/Valexandre/france-geojson/master/arrondissements-millesimes0.geojson")%>%st_transform(crs=2154) | |
| DepsMetro<-st_read("https://raw.githubusercontent.com/Valexandre/france-geojson/master/departements.geojson")%>% | |
| filter(nchar(code)==2)%>% |
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
| --- | |
| title: "Build a Q&A from Slack conversation" | |
| author: "Olivier Gimenez" | |
| date: "5/19/2021, 9/7/2021" | |
| output: html_document | |
| --- | |
| ```{r setup, include=FALSE} | |
| knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE) | |
| ``` |
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
| # load packages | |
| library(tidyverse) | |
| theme_set(theme_light(base_size = 16)) | |
| library(gganimate) | |
| library(magick) | |
| # deer data, 19 "success" out of 57 "attempts" | |
| survived <- 19 | |
| released <- 57 |
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) | |
| options(warn = -1) # suppress warnings | |
| # read in the rings as character strings | |
| ring <- data.frame(inner_ring = "00000001000000000001000001001000000001010001111111111111111111111111111111111111", | |
| middle_ring_first = "00000011010000001001000000011100000010000000010100000001100100011111111111111111", | |
| middle_ring_second = "00000101000000001000000000100100000011100000000111000001001100011111111111111111") | |
| end <- seq(10, 80, by = 10) # create vector of upper bound for each chunk of 10 bits |
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
| # je suis parti de ce post | |
| # https://darrenjw.wordpress.com/2012/11/20/getting-started-with-bayesian-variable-selection-using-jags-and-rjags/ | |
| # je n ai utilise que le code de la section "Basic variable selection" c'est a dire que | |
| # j ai laisse tombé les modifs sur le code que l'auteur propose dans les sections | |
| # "Variable selection with random effects" et "Variable selection with random effects and a prior on the inclusion probability" | |
| # j ai rajoute des lignes de code a la fin pour calculer les probabilites a posteriori des modeles | |
| # (voir par exemple la table 2 dans https://dl.dropboxusercontent.com/u/23160641/my-pubs/Gimenezetal2009Evolution.pdf) |
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
| #------- inspiration: https://www.nytimes.com/2020/12/28/science/math-conway-game-of-life.html | |
| #------- see also https://medium.com/tebs-lab/optimizing-conways-game-of-life-12f1b7f2f54c | |
| #---- implementation 1 | |
| install.packages("fun") | |
| library(fun) | |
| demo("GameOfLife") | |
| #---- implementation 2 (https://www.r-bloggers.com/2012/11/fast-conways-game-of-life-in-r/) |
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
| # illustrates grouped lasso with simulations | |
| # with normal and non-normal responses | |
| # and a mix and discrete/continuous predictors | |
| #----- normal response | |
| library(gglasso) | |
| create_factor <- function(nb_lvl, n = 100 ){ | |
| factor(sample(letters[1:nb_lvl],n, replace = TRUE))} |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
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
| h1;h2;h3;h4;h5;h6;h7;males;females | |
| 1;1;1;1;1;1;0;1;0 | |
| 1;1;1;1;1;0;0;0;1 | |
| 1;1;1;1;0;0;0;1;0 | |
| 1;1;1;1;0;0;0;0;1 | |
| 1;1;0;1;1;1;0;0;1 | |
| 1;1;0;0;0;0;0;1;0 | |
| 1;1;0;0;0;0;0;1;0 | |
| 1;1;0;0;0;0;0;1;0 | |
| 1;1;0;0;0;0;0;1;0 |
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
| # Fit model combining live recapture and dead recoveries in Jags using SSM formulation of multistate models | |
| # Warning: if initial values are generated from the ld.init() function, we failed at recovering the values | |
| # used to simulate the data; everything goes well if we use the true latent states (data are simulated) as initial values | |
| # Define function to simulate multistate capture-recapture data | |
| simul.ms <- function(PSI.STATE, PSI.OBS, marked, unobservable = NA){ | |
| # Unobservable: number of state that is unobservable | |
| n.occasions <- dim(PSI.STATE)[4] + 1 | |
| CH <- CH.TRUE <- matrix(NA, ncol = n.occasions, nrow = sum(marked)) | |
| # Define a vector with the occasion of marking |