Fleeting

A temporary collection of notes

ITV Experiments Spring 2013: Randomization Inference

| Comments

Today we might use some of the new features of the RItools package for doing randomization inference. We’ll be working with the handout that you completed last term slightly updated here

To get this, as yet in-progress, undocumented, and unreleased version do the following:

1
2
3
4
5
install.packages("devtools")
library("devtools")
.libPaths(getwd()) # <- installs to the working directory rather than the system
install_github("RItools", user = "markmfredrickson", ref = "randomization-distribution")
library("RItools",lib.loc=getwd())

To test a sharp null using this package you can do the following (assuming you’ve loaded the news.df data frame.

First you have to represent the design of the study. We call them ‘samplers’ because ‘random assigners’ or ‘design machines’ seemed strange:

1
2
3
4
5
6
7
paired.assignment.sampler<-simpleRandomSampler(z=news.df$z,
                                               b=news.df$s)
## test it : should have 8 rows, 10 columns, etc..
( ten.experiments<-paired.assignment.sampler(10) )
## Does it do the right thing?
## One test (not the only one):
all(colSums(ten.experiments$samples)==4)

Given the design, we need a hypothesis (here assumed by default to be the sharp null of no effects) and a test statistic (here using the mean difference):

1
2
3
4
5
6
7
8
9
10
11
12
testH0<-RItest(y=news.df$r,
               z=news.df$z,
               test.stat=mean.difference,
               p.value=upper.p.value,
               sampler=paired.assignment.sampler,
               samples=100,
               include.distribution=T)
## The p-value
summary(testH0)

## The distribution of the test statistic
table(testH0@distribution)

PS 531 - Class 3 - What Is a Confidence Interval?

| Comments

Confidence intervals summarize many hypothesis tests, at least, approximately (or exactly if they arise from direct inversion of the hypothesis tests themselves). Confidence intervals also encourage us to make limits or boundaries on what kinds of hypotheses ought to be understood as plausible (in contrast with $p$-values, where we have only a continuous measure of discordance between the observations and the hypothesis.

The handout for work in class is here.

The commented handout here.

The source code (without my comments) for work in class is here. Using the source code may make cutting and pasting code easier. Plus it allows you to see what Sweave is like.

PS 531 - Class 2 - What Is a Hypothesis Test?

| Comments

Today we move from description to begin to engage with statistical inference (not causal inference). When I say “statistical inference” I refer to procedures like hypothesis tests and the creation of confidence intervals (or the creation of posterior distributions or functions thereof).

The handout for work in class is here.

The commented handout is here.

The source for both handouts is here.

Resources on Study Pre-Registration

| Comments

We discussed the pre-registration of studies in class yesterday in the context of the amazingly detailed exemplar from Ana de la O and Fernando Martel GarcĂ­a.

Here are some other resources on this topic (thanks to a posting by Brendan Nyhan on the polmeth listserv):

Registered Reports: A new publishing initiative at Cortex

Special Issue of Social Psychology: “Replications of Important Results in Social Psychology”

See also the pilot test of a system by the Experiments in Government and Politics group here.

PS 531 - Class 0 - Review and Overview: What Is at Stake in Choosing a Strategy for Description?

| Comments

Soon we will be talking about fitting models and then about testing hypotheses. Yet, we will always return to the topic of description throughout the course. Description, after all, is most important. Description tells the story.

The handout for work in class is here.

The raw R code for the handout for work in class is here.

The commented handout is here.

The raw R+LaTeX code for the handout (my original version) here.