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
#will have to decide about the html later. | |
#probably need to make digits work in a sane sort of way. | |
fixedEffectFrame <- function(x,digits=c(2,2,2)) { | |
data.frame("Coefficient"=round(fixef(x),digits[1]),"Std. Error"=round(sqrt(diag(vcov(x))),digits[2]),"t value"=abs(round(fixef(x)/sqrt(diag(vcov(x))),digits[3])),check.names=FALSE) | |
} | |
varcortau <- function(lme4.model,groupLevel="WAISID",digits=2) { | |
model.var <- VarCorr(lme4.model)[[groupLevel]] | |
model.var[lower.tri(model.var)] <- attr(model.var,"correlation")[lower.tri(attr(model.var,"correlation"))] | |
REmat <- summary(lme4.model)@REmat |
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
# Paired Sample t-tests: Yes, Virginia there is an effect size for that! | |
There are a plethora of options, Cohen’s d, a tweaked version of Glass’ $\Delta$ (1976): $\Delta_{RM}$ (Gibbons et al., 1993), dIGPP (Becker, 1988), generalized $\eta^2$ (Bakeman, 2005; Olejnik & Algina, 2003), and r (which in this context is a square rooted alias for partial eta squared). Of these I prefer generalized $\eta^2$ or r. Why r I hear you say. I’ve never seen r used before in this context. | |
A paired samples t is just a one sample t-test of the differences. The advantage of using r is that it is well known and amenable to meta-analysis. The interpretation does take a couple steps to think through, but I thought I’d try to help point you in the right direction. You’ll recall that a paired samples t-test reduces to a within samples ANOVA with 1 df in the numerator. Just as r is the square root of the proportion explained, so too is r (in this context) the square root of the proportion of variance explained by estimatin |
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
sim <- function(places=3,N=20,FUN=round,...) { | |
SSr <- function(x) {sum((FUN(x,places)-mean(FUN(x,places)))^2)} | |
SS <- function(x) {sum((x-mean(x))^2)} | |
y <- rnorm(N,...) | |
return(abs(SSr(y)-SS(y))) | |
} | |
mean(replicate(20000,sim())) |
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
#repsych is on github and is here only for the glibrary idiom | |
library(repsych) | |
#install and load the following packages | |
glibrary(whisker, lubridate, magrittr, rappdirs, awsjavasdk, rJava) | |
if (!aws_sdk_present()) { | |
install_aws_sdk() | |
} | |
load_sdk() |
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
#' Send a message to Slack | |
#' | |
#' To use, set options(zapier_slack_webhook="yourZapierPostWebhookHere") | |
#' | |
#' @param message | |
#' @param channel | |
#' @param bot_name | |
#' @param bot_icon_url | |
#' @param image_url | |
#' @param emoji |
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
#drops all numbers prior to the decimal place | |
dropLeading <- function(num) { | |
sub("^0\\.", ".",as.character(num)) | |
} |
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 all variables plotted along a given axis in a ggplot. | |
getPlottedVals <- function(ggplotObj,axis=c("x","y"),includeLayers=TRUE) | |
{ | |
if (is.null(axis)) {stop("In getPlotted: Argument axis not specified.")} | |
getValAxis <- function(.q,axis=c("x","y")) { | |
as.data.table(.q$data)[,eval(.q$mapping[[axis]])] | |
} | |
getLayerAxis <- function(tmpLayer,axis=c("x","y")) { | |
if (!any(class(tmpLayer$data) %in% "waiver") & (any(class(tmpLayer$data)=="data.frame"))) { | |
return(getValAxis(tmpLayer,axis)) |
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
//Modified from: http://forums.adobe.com/message/4496260#4496260 to list comments in page number order | |
//Open PDF | |
//Control-J | |
//Control-A (select the junk already in the console) | |
//Control-V (paste in code) | |
//Control-A | |
//Control-Enter | |
//It will freeze for a while while it does the work | |
this.syncAnnotScan(); | |
var a = this.getAnnots({ |
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
# Very raw dump of prototype code that allows for connection to a JDBC db via a ad-hoc one node cluster. This demo code was designed to connect to redshift using Amazon's JDBC drivers - because sometimes you just want to do things the hard way | |
# To make this work, you'll need to update the classPath, driverPath, and of course, the host settings. | |
#library(plyr); needs to be available, but doesn't need to be attached | |
library(whisker) | |
library(R6) | |
library(logging) | |
library(R.utils) #tempvar | |
library(parallel) #makeCluster and friends |
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(parallel) | |
saveRDS.xz <- function(object,file,threads=parallel::detectCores()) { | |
pxzAvail <- any(grepl("(XZ Utils)",system("pxz -V",intern=TRUE))) | |
if (pxzAvail) { | |
con <- pipe(paste0("pxz -T",threads," > ",file),"wb") | |
base::saveRDS(object, file = con) | |
close(con) | |
} else { | |
saveRDS(object,file=file,compress="xz") |
NewerOlder