Skip to content

Instantly share code, notes, and snippets.

View mcmtroffaes's full-sized avatar

Matthias C. M. Troffaes mcmtroffaes

View GitHub Profile
@mcmtroffaes
mcmtroffaes / stderrcorrelated.R
Last active August 29, 2015 14:04
standard error of a correlated sample
# Return start of xs as long as f evaluates to TRUE
TakeWhile <-
function(f, x, nomatch = NULL)
{
pos = Position(Negate(f), x, nomatch = 0L)
if (pos == 0L) {
## f is TRUE everywhere
if (length(x) > 0L)
x
else
@mcmtroffaes
mcmtroffaes / classification.r
Last active August 8, 2017 11:59
sample script for classification
# classification.r: generic R library for classification
# Copyright (C) 2014 Matthias C. M. Troffaes <matthias.troffaes@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@mcmtroffaes
mcmtroffaes / kfcv.r
Last active November 16, 2018 02:41
k-fold cross validation script for R
kfcv.sizes = function(n, k=10) {
# generate sample sizes for k-fold cross validation on a data set of
# size n
# author: Matthias C. M. Troffaes
# date: 22 Nov 2010
# license: GPLv3
# usage:
#
# kfcv.sizes(n, k=...)
effectsplot = function(formula, data=NULL, main=NULL, xlab=NULL, ylab=NULL) {
# author: Matthias C. M. Troffaes
# date: 26 Nov 2009
# license: GPLv3
# usage:
#
# effectsplot(y ~ x, data=..., main=..., xlab=..., ylab=...)
#
# where the last three arguments are optional, and you should mind that xlab
# is a *vector* of two strings (first for group effect label, second for