This file contains 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
(require 'offlineimap) | |
(add-to-list 'load-path "~/.emacs.d/lib/mu4e") | |
(require 'mu4e) | |
(require 'mu4e-maildirs-extension) | |
(mu4e-maildirs-extension) | |
(setq mu4e-drafts-folder "/drafts" | |
mu4e-sent-folder "/sent" | |
mu4e-trash-folder "/trash") | |
(setq mu4e-maildir-shortcuts |
This file contains 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
## ESTIMATE SAMPLE SIZE NEEDED to achieve a given power in univariate twin studies. | |
## | |
## Input: | |
## pmz: sampling fraction MZ/DZ | |
## tmz: intraclass correlation for MZ twins | |
## tdz: intraclass correlation for DZ twins | |
## alpha: level I risk level | |
## beta: level II risk level (power = 1 - beta) | |
## | |
## Output: |
This file contains 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(lme4) | |
data(sleepstudy) | |
## Fit individual regression lines for each subject | |
dfrm <- coef(lmList(Reaction ~ Days | Subject, sleepstudy)) | |
## Estimate parameters of a random intercept and random intercept and slope model | |
m1 <- lmer(Reaction ~ Days + (1 | Subject), data=sleepstudy) | |
m2 <- lmer(Reaction ~ Days + (Days | Subject), data=sleepstudy) |
This file contains 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
RMDFILE=demo-rmd-pandoc | |
PANDOC=~/.cabal/bin/pandoc | |
all: | |
Rscript -e "require(knitr); require(markdown); knit('$(RMDFILE).rmd', '$(RMDFILE).md'); purl('$(RMDFILE).rmd')" | |
${PANDOC} --mathjax --toc -B header.html -A footer.html --bibliography refs.bib --css markdown.css -s $(RMDFILE).md -o $(RMDFILE).html | |
This file contains 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
# Compute % agreement between any two columns in a data.frame | |
dfrm <- data.frame(replicate(18, sample(letters[1:3], 30, replace=TRUE))) | |
agree <- function(df, i, j) { | |
tab <- table(df[,c(i,j)]) | |
sum(diag(tab))/sum(tab) | |
} | |
# Solution 1 | |
vagree <- Vectorize(agree, vectorize.args=list("i","j")) |
This file contains 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
#! /usr/bin/env sh | |
# Post-process Stata do -> log file. | |
# We should ensure that we use the correct stata program | |
# (e.g., might be stata, stata-mp, etc.). I'll put this here | |
# for later update. | |
STATA="$(which stata)" | |
# Process command line options |
This file contains 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
# simulate some data | |
set.seed(88) | |
n <- 30 | |
x <- runif(n) | |
y <- 1.2 + 0.8*x + rnorm(n) | |
g <- sample(letters[1:2], n, replace=TRUE) | |
my.df <- data.frame(x=x, y=y, grp=factor(g)) | |
# show data structure | |
dput(my.df) |
This file contains 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
mha <- 1 # mean under the alternative | |
es <- 2 # observed effect (deviation from mean under H0) | |
x <- seq(-6, 6, length=1000) | |
dh0 <- dnorm(x, 0, 1) | |
show.it <- function(es, mha, verbose=FALSE) { | |
dh1 <- dnorm(x, mha, 1) | |
plot.new() | |
plot.window(xlim=range(x), ylim=c(0,.6)) |
This file contains 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
tufte.boxplot <- function(x, g) { | |
k <- nlevels(g) | |
crit.val <- tapply(x, g, median) | |
plot(1:k, crit.val, ylim=c(min(x)*1.1, max(x)*1.1), pch=19, | |
xlab=deparse(substitute(g)), ylab=deparse(substitute(x))) | |
for (i in 1:k) { | |
tmp <- boxplot.stats(x[as.numeric(g)==i]) | |
segments(i, tmp$stats[1], i, tmp$stats[2]) | |
segments(i, tmp$stats[4], i, tmp$stats[5]) | |
points(rep(i, length(tmp$out)), tmp$out, cex=.8) |
This file contains 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
@article{Narrow2009, | |
Author = {Narrow, W.E. and Kuhl, E.A. and Regier, D.A.}, | |
Journal = {World Psychiatry}, | |
Month = {Jun}, | |
Number = {2}, | |
Pages = {88-89}, | |
Title = {{DSM-V} perspectives on disentangling disability from | |
clinical significance}, | |
Volume = {8}, | |
Year = {2009}} |