Skip to content

Instantly share code, notes, and snippets.

Ben Bolker bbolker

Block or report user

Report or block bbolker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View bigcorPar.r
bigcorPar <- function(x, nblocks = 10, verbose = TRUE, ncore="all", ...){
library(ff, quietly = TRUE)
require(doMC)
if(ncore=="all"){
ncore = multicore:::detectCores()
registerDoMC(cores = ncore)
} else{
registerDoMC(cores = ncore)
}
@bbolker
bbolker / lme4_gamma_profile
Created Aug 21, 2018
example of profiling a gamma model in lme4
View lme4_gamma_profile
library(lme4)
set.seed(101)
dd <- data.frame(x=rnorm(200),f=factor(rep(1:10,each=20)))
dd$y <- simulate(~x+(1|f),
newdata=dd,
newparams=list(beta=c(10,1),
theta=1,
sigma=5),
family=Gamma(link="identity"))[[1]]
## NB not sure what sigma really is here??? must be shape parameter
@bbolker
bbolker / lme4_gamma_profile
Created Aug 21, 2018
example of profiling a gamma model in lme4
View lme4_gamma_profile
library(lme4)
set.seed(101)
dd <- data.frame(x=rnorm(200),f=factor(rep(1:10,each=20)))
dd$y <- simulate(~x+(1|f),
newdata=dd,
newparams=list(beta=c(10,1),
theta=1,
sigma=5),
family=Gamma(link="identity"))[[1]]
## NB not sure what sigma really is here??? must be shape parameter
@bbolker
bbolker / geom_cstar
Created Jul 28, 2018
a ggplot geom that connects points to the centroid
View geom_cstar
##'
##' @examples
##' dd <- data.frame(x=rnorm(10),y=rnorm(10))
##' ggplot(dd,aes(x,y))+
##' geom_point() +
##' stat_centseg()
##' ggplot(dd,aes(x,y))+
##' geom_point() +
##' stat_centseg(cfun=median)
##' data("Gasoline",package="nlme")
@bbolker
bbolker / xapply.R
Created Jun 29, 2017
a "factorial apply" function
View xapply.R
#' apply a function to a factorial combination of elements of lists
#' returns (if \code{FLATTEN=TRUE}) a flat list (with length equal to the product of the
#' lengths of the input lists) of results, along with a \code{grid} attribute containing
#' a data frame giving the values used for each element in the list
#' @param FUN function to apply
#' @param ... list of vectors to apply to
#' @param FLATTEN
#' @param MoreArgs additional arguments to pass to \code{FUN}
#' @param GlobalVars list of names of variables in global environment needed for parallel runs
#' @param .progress progress bar?
@bbolker
bbolker / persist.rmd
Last active Jan 4, 2016
runr test with persistent python3
View persist.rmd
---
title: "runr test"
date: "`r format(Sys.time(), '%H:%M %d %B %Y ')`"
author: Ben Bolker
---
```{r opts,message=FALSE,echo=FALSE,warning=FALSE}
library("knitr")
library("runr")
py <- proc_python()
You can’t perform that action at this time.