Skip to content

Instantly share code, notes, and snippets.

View vasishth's full-sized avatar
💭
My status is high.

Shravan Vasishth vasishth

💭
My status is high.
View GitHub Profile
@vasishth
vasishth / powerinflationindex
Last active August 27, 2015 13:16
Power inflation index
## true effect size:
D<-seq(1,250,by=1)
## SE from a study:
se<-46
## sample size
n<-37
## typical SD:
stddev<-se*sqrt(n)
## rejection value (absolute) under null:
@vasishth
vasishth / test.tex
Created January 17, 2016 19:24
Example exam template for automating exams and homework using the exam package.
\documentclass[10pt,a4paper]{article}
%% packages
\usepackage{a4wide,verbatim,Sweave,url}
%% new environments
\newenvironment{question}{\item}{}
\newenvironment{solution}{\comment}{\endcomment}
\newenvironment{answerlist}{\renewcommand{\labelenumi}{(\alph{enumi})}\begin{enumerate}}{\end{enumerate}}
@vasishth
vasishth / solutiontest.tex
Created January 17, 2016 19:25
The solutions to the automated test.
\documentclass[10pt,a4paper]{article}
%% packages
\usepackage{a4wide,verbatim,Sweave,url}
%% new environments
\newenvironment{question}{\item \textbf{Problem}\newline}{}
\newenvironment{solution}{\textbf{Solution}\newline}{}
\newenvironment{answerlist}{\renewcommand{\labelenumi}{(\alph{enumi})}\begin{enumerate}}{\end{enumerate}}
@vasishth
vasishth / pnorm1.Rnw
Last active January 17, 2016 19:27
Example automated exercise for statistics introduction course
<<echo=FALSE, results=hide>>=
## DATA GENERATION
mean.val<-round(rnorm(1,mean=100,sd=100),digits=0)
sd.val<-round(rnorm(1,mean=100,sd=10),digits=0)
upper<-round(rnorm(1,mean=100,sd=100)+50,digits=0)
lower<-round(rnorm(1,mean=100,sd=100)-100,digits=0)
sol<-pnorm(upper,mean=abs(mean.val),sd=abs(sd.val))-pnorm(lower,mean=abs(mean.val),sd=abs(sd.val))
sol<-round(sol,digits=3)
@vasishth
vasishth / ExampleExamCode.R
Last active February 2, 2020 01:15
Example code for automatically generating R exercises and exams
## Load library:
library("exams")
## exam questions:
myexamlist<-list("pnorm1","sesamplesize1multiplechoice")
## output directory
## create new test dir if one does not exist:
files.list<-system("ls",intern=TRUE)
@vasishth
vasishth / sesamplesize1multiplechoice.Rnw
Created January 17, 2016 21:25
An example question with a multiple choice question.
<<echo=FALSE, results=hide>>=
## DATA GENERATION
mean.val<-round(rnorm(1,mean=100,sd=10),digits=0)
sd.val<-round(abs(rnorm(1,mean=10,sd=10)),digits=0)
n<-round(abs(rnorm(1,mean=100,sd=10)),digits=0)+1
se1<-round(sd.val/sqrt(n),digits=3)
se2<-round(sd.val/sqrt(n^2),digits=3)
questions <- character(5)
library(lme4)
## load data
hindi10<-read.table("datacode/hindi10a.txt",header=TRUE)
## skipping: 1 if word is skipped, 0 otherwise
skip<-ifelse(hindi10$TFT==0,1,0)
hindi10$skip<-skip
summary(hindi10$word_complex)
## make a sum contrast for illustration
@vasishth
vasishth / gist:f313df5b50f8902a4e18e965253178e5
Created March 9, 2024 06:33
The width of a CI is simply a function of the estimated sd
nsim<-100000
sd_est<-width<-rep(NA,nsim)
for(i in 1:nsim){
y<-rnorm(10)
sd_est[i]<-sd(y)
ci<-t.test(y)$conf.int
width[i]<-ci[2]-ci[1]
}
plot(width,sd_est)