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(CircStats) | |
#define a data generator for the uvm model | |
get_mix_data = function( n , rho , kappa , seed ){ | |
set.seed(seed) | |
to_return = rep(NA,n) | |
trial_is_vm = as.logical(rbinom(n,1,rho)) | |
to_return[trial_is_vm] = rvm(sum(trial_is_vm),pi,kappa) | |
to_return[!trial_is_vm] = runif(sum(!trial_is_vm),0,2*pi) | |
to_return = to_return-pi #center the data on 0 |
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
ezANOVA <- | |
function( | |
data | |
, dv | |
, wid | |
, within = NULL | |
, between = NULL | |
, observed = NULL | |
, diff = NULL | |
, reverse_diff = FALSE |
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
#A function to obtain predictions from a fitted lmer object. | |
#If to_predict is null, the function will attempt to build a | |
#design matrix for prediction from the information in the fit | |
#itself. If a .() object is passed to as to_predict, variables | |
#listed in to_return are used to create the design matrix. A | |
#data frame may also be passed as to_predict. | |
ezPredict <- | |
function( | |
fit |
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
extrema_c = function (y, ndata = length(y), ndatam1 = ndata - 1){ | |
minindex <- maxindex <- NULL | |
nextreme <- 0 | |
cross <- NULL | |
ncross <- 0 | |
z1 <- sign(diff(y)) | |
index1 <- seq(1, ndatam1)[z1 != 0] | |
z1 <- z1[z1 != 0] | |
if(!(is.null(index1) || all(z1 == 1) || all(z1 == -1))){ |
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
#define two useful helper functions | |
colMean = function(x){ | |
dimx = dim(x) | |
.Internal(colMeans(x,dimx[1],dimx[2],na.rm=TRUE)) | |
} | |
colVar = function(x){ | |
dimx = dim(x) | |
x.mean = .Internal(colMeans(x,dimx[1],dimx[2],na.rm=TRUE)) | |
err = t(t(x)-x.mean) | |
err.sq = err*err |
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(ez) | |
data(ANT) | |
######## | |
#this will work | |
######## | |
rt = ezMixed( | |
data = ANT[ANT$error==0,] | |
, dv = .(rt) | |
, random = .(subnum) |
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(plyr) | |
a = read.table('temp.txt') | |
names(a) = c('trial','event','time') | |
a$row = as.numeric(row.names(a)) | |
a$event = factor(a$event,levels=c('collect_data','A','B','C','write_data')) | |
b = ddply( | |
.data = a | |
, .variables = .(trial,event) |
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
fptcdf = function(z,x0max,chi,driftrate,sddrift) { | |
zs = z*sddrift | |
zu = z*driftrate | |
chiminuszu = chi-zu | |
xx = chiminuszu-x0max | |
chizu = chiminuszu/zs | |
chizumax = xx/zs | |
tmp1 = zs*(dnorm(chizumax)-dnorm(chizu)) |
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
$ sudo ./configure --with-x=no --enable-R-shlib | |
checking build system type... x86_64-unknown-linux-gnu | |
checking host system type... x86_64-unknown-linux-gnu | |
loading site script './config.site' | |
loading build-specific script './config.site' | |
checking for pwd... /bin/pwd | |
checking whether builddir is srcdir... yes | |
checking for working aclocal... missing | |
checking for working autoconf... missing | |
checking for working automake... missing |
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
#Load the CicStats package | |
library(CircStats) | |
#Define a customization of circ.mean{CircStats} that permits weighting observations | |
circ.weighted.mean = function (x,rho){ | |
sinr = sum(rho*sin(x)) | |
cosr = sum(rho*cos(x)) | |
circmean = atan2(sinr, cosr) | |
return(circmean) | |
} |
OlderNewer