# Hyde Park Purse snatching example # # The file replications the Hyde Park purse snatching # intervention analysis reported in Brandt and Williams. 2001 # "A Linear Poisson Autoregressive Model: the PAR(p)" # Political Analysis 9(2): 164-184. # # # Patrick Brandt # # pbrandt@utdallas.edu # School of Economic, Politica and Policy Sciences # University of Texas, Dallas # # This file contains no warranty or guarantee of performance. # Use at your own risk for non commercial use # # April 2004: This file replicates the analysis in Brandt and # Williams in R >=1.9. It also demonstrates how to use the R version # of the PESTS code source("../pests.r") # Set up data matrices HydePark <- read.table(file = "hydepark.txt", header=F, col.names=c("Snatched.Purses")) attach(HydePark) # Define the intervention variable whistle <- c(rep(0,41),rep(1,30)) # Now plot the time series plot(ts(HydePark, start=c(1969,1), freq=12), ylab="Snatched Purses", main="Hyde Park Purse Snatching Data") # Do a Poisson regression to get some consistent starting values HydePark.Poisson <- glm(Snatched.Purses ~ whistle, family=poisson) summary(HydePark.Poisson) # PAR(1) Model HydePark.PAR1 <- Parp(Snatched.Purses ~ whistle, p=1) # PAR(2) Model HydePark.PAR2 <- Parp(Snatched.Purses ~ whistle, p=2) # PEWMA model -- include -1 so we omit the intercept. HydePark.PEWMA <- Pewma(Snatched.Purses ~ -1 + whistle) # Replicate McCleary and Hay's (1980) ARIMA(2,0,0) HydePark.arima <- arima(HydePark, order=c(2,0,0), xreg=whistle) # Print / summarize the results. print(summary(HydePark.Poisson)) print(HydePark.PAR1) print(HydePark.PAR2) print(HydePark.PEWMA) print(HydePark.arima) # Compute the impact multipliers for the PAR models. These are by # default for one unit changes in the intervention variable. parp.multipliers(HydePark.PAR1) parp.multipliers(HydePark.PAR2)