https://gist.github.com/search?q=user%3A%40me&ref=searchresults
Uses @me to refer to itself in the gist search query.
Type this into Github Gist Search (https://gist.github.com/)
user:BoQsc your search query
| # Source: http://www.cookbook-r.com/Manipulating_data/Converting_between_data_frames_and_contingency_tables/#countstocases-function | |
| # Convert from data frame of counts to data frame of cases. | |
| # `countcol` is the name of the column containing the counts | |
| countsToCases <- function(x, countcol = "Freq") { | |
| # Get the row indices to pull from x | |
| idx <- rep.int(seq_len(nrow(x)), x[[countcol]]) | |
| # Drop count column | |
| x[[countcol]] <- NULL |
| `simulate.gamm` <- function(object, nsim = 1, seed = NULL, newdata, | |
| freq = FALSE, unconditional = FALSE, ...) { | |
| if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE)) | |
| runif(1) | |
| if (is.null(seed)) | |
| RNGstate <- get(".Random.seed", envir = .GlobalEnv) | |
| else { | |
| R.seed <- get(".Random.seed", envir = .GlobalEnv) | |
| set.seed(seed) | |
| RNGstate <- structure(seed, kind = as.list(RNGkind())) |
https://gist.github.com/search?q=user%3A%40me&ref=searchresults
Uses @me to refer to itself in the gist search query.
Type this into Github Gist Search (https://gist.github.com/)
user:BoQsc your search query
| ## Procuces an animation showing how weighted basis functions combine to produce a sline | |
| ## - this version is for a cubic regression spline basis | |
| ## packages required | |
| library('ggplot2') | |
| library('tibble') | |
| library('tidyr') | |
| library('dplyr') | |
| library('mgcv') | |
| library('mvnfast') |
| #' Description | |
| #' This file runs a live election-night forecast based on The Economist's pre-election forecasting model | |
| #' available at projects.economist.com/us-2020-forecast/president. | |
| #' It is resampling model based on https://pkremp.github.io/update_prob.html. | |
| #' This script does not input any real election results! You will have to enter your picks/constraints manually (scroll to the bottom of the script). | |
| #' | |
| #' Licence | |
| #' This software is published by *[The Economist](https://www.economist.com)* under the [MIT licence](https://opensource.org/licenses/MIT). The data generated by *The Economist* are available under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/). | |
| #' The licences include only the data and the software authored by *The Economist*, and do not cover any *Economist* content or third-party data or content made available using the software. More information about licensing, syndication and the copyright of *Economist* content can be fou |
| library(glmmTMB) | |
| library(mgcv) | |
| ######################################################################### | |
| ## Function to create prediction matrices from mgcv for glmmTMB | |
| ## from ?mgcv::smooth2random | |
| ######################################################################## | |
| s2rPred <- function(sm,re,data) { | |
| ## Function to aid prediction from smooths represented as type==2 | |
| ## random effects. re must be the result of smooth2random(sm,...,type=2). |
| library(mgcv) | |
| library(spdep) | |
| library(sf) | |
| library(ggplot2) | |
| # Columbus crime data from mgcv/spdep | |
| example(columbus) | |
| # Make a neighborhood object compatible with mgcv's MRF | |
| nb <- poly2nb(columbus) |
| // LICENSE | |
| // ======= | |
| // Copyright (c) 2017-2019 Advanced Micro Devices, Inc. All rights reserved. | |
| // ------- | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation | |
| // files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, | |
| // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the | |
| // Software is furnished to do so, subject to the following conditions: | |
| // ------- | |
| // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the |
| // Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is | |
| // furnished to do so, subject to the following conditions: | |
| // | |
| // The above copyright notice and this permission notice shall be included in |