Skip to content

Instantly share code, notes, and snippets.

View jvcasillas's full-sized avatar

Joseph V. Casillas jvcasillas

View GitHub Profile
@jvcasillas
jvcasillas / beamer-arrows-tikz.tex
Created November 19, 2012 15:25
beamer-arrows-in-itemize
\tikzstyle{every picture}+=[remember picture]
\everymath{\displaystyle}
\begin{frame}[m]\frametitle{}
\tikzstyle{na} = [baseline=-.5ex]
\begin{itemize}[<+-| alert@+>] % makes everything red
\item Sujeto
\tikz[na] \node[coordinate] (n1) {};
@jvcasillas
jvcasillas / tikz-with-overlay.tex
Created November 20, 2012 00:05
tikz-with-image
\begin{frame}[m]\frametitle{}
\begin{tikzpicture}
\node[] (image) at (0,0) {\includegraphics[scale=.27]{btard_ae}\includegraphics[scale=.27]{btemp_ae}\includegraphics[scale=.27]{mono_ae}};
\end{tikzpicture}
\end{frame}
\begin{frame}[m]\frametitle{}
\begin{tikzpicture}
\node[] (image) at (0,0) {\includegraphics[scale=.27]{btard_ae}\includegraphics[scale=.27]{btemp_ae}\includegraphics[scale=.27]{mono_ae}};
\draw [-latex] (-5.35,.5) to[bend right=15] (-4.45,-0.15);
@jvcasillas
jvcasillas / tarea5Rcode.R
Created December 6, 2012 02:03
r_code_for_ident_data
# A couple things about this script...
# All text that comes after a "#" sign implies a comment that will not
# be evaluated by R. All you need to do is copy and paste the contents
# of this script into R and it will perform an ANOVA and make a graph.
# It is important that your data (in your data file from the hw) are
# in the correct format. You need to have the following headers for
# each column: "participant", "ending", "stimulus", "proportion".
# Check the example file "tarea5.txt" if you need to compare.
# The following command reads the data file into R.
@jvcasillas
jvcasillas / heat_plot
Created May 7, 2013 15:48
heat plots in R
library(ggplot2)
plot <- ggplot(heat_plot, aes(fpro, dpro))
plot + geom_tile(aes(fill=mean_choice), colour="white") +
scale_fill_gradient(low="white", high="steelblue")
@jvcasillas
jvcasillas / gist:6940799
Created October 11, 2013 19:40
GLMER graph info
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Generalized Linear Models
with binary categorical data
with binomial error structure
and logit link function
Categorical data is heteroskedastic. Residuals are not normally distributed. It violates assumptions of linear models. It can be approximated as a logistic curve (s-like-curve). This curve represents probability values: probability of observing 1 or 0 at y when steps in x change. (Ideal for perception data.)
model = glm(response ~ step in continuum or Hz, data=study, family="binomial") # regular generalized (logistic) linear model
@jvcasillas
jvcasillas / ident_sigmoid
Created May 14, 2014 17:24
ident_sigmoid
# Plot Spectrum Proportion
my_data$group <- factor(my_data$group, levels = c("EL", "NE", "LL"))
df<-with(my_data, aggregate(fpro, list(group=group, fstim=fstim), mean))
df$se<-with(my_data, aggregate(fpro, list(group=group, fstim=fstim), function(x) sd(x)/sqrt(10)))[,3]
gp<-ggplot(df, aes(x=fstim, y=x, colour=group, ymin=x-se, ymax=x+se))
gp +geom_line(aes(linetype=group), size = .4) +
geom_point(aes(shape=group)) +
geom_ribbon(alpha = 0.15, linetype=0) +
#geom_errorbar(aes(ymax=x+se, ymin=x-se)) +
ylim(0, 1) +
@jvcasillas
jvcasillas / dPrime
Last active August 29, 2015 14:11
dPrime
#####################################
# Functions for linguistic research #
# Joseph V. Casillas #
# Last update: 12-10-2014 #
#####################################
# Calculate d prime in discrimination experiments.
# Takes a df with the columns:
# - stimDiff (actual stimuli are different)
# - stimSame (actual stimuli are the same)
@jvcasillas
jvcasillas / euc.dist
Created April 11, 2015 22:43
Euclidean distance
euc.dist <- function(x1, x2){
x <- sqrt(sum((x1 - x2)^2))
return(x)
}
@jvcasillas
jvcasillas / vowel_plot_example.R
Last active January 22, 2018 02:25
Example for plotting vowels using ggplot
# Plot vowel formants
# - Include elipses,
# - group/vowel means
# - greyscale
# Load tidyverse and phonR package (I choose this because you said you
# had alrady used it)
library(phonR)
library(tidyverse)
@jvcasillas
jvcasillas / tost_ex.R
Created February 21, 2019 18:29
Example of two one-sided t tests (to test equivalence)
# Load libraries
library("tidyverse")
library("TOSTER")
# Set seed for reproducibility
set.seed(10)
# Working memory means for 3 groups
wm_n <- rnorm(mean = 8.67, sd = 1.15, n = 12)
wm_nin <- rnorm(mean = 9.04, sd = 2.11, n = 26)