-
AU: Government moves to encourage use of Open Source Software | ePractice
-
The Daily Tar Heel :: Faculty, students get a glimpse into Sakai
-
BitTorrent Expands Its Distribution Platform to Ebooks | Piracy Network
-
Protecting Privacy Through Cybersecurity | Center for Strategic and International Studies
Technology Policy Links (weekly)
Technology Policy Links (weekly)
Stata DO-File Conversion to [R] Script File
I’m working on a research replication projects for my Stats class and have run into a little trouble converting a Stata DO-File to [R] script. I’m working to extend the original research of Craig Depken and Trisha Bezmen which was presented in “Influences on software piracy: Evidence from the various United States“. Thankfully Dr. Depken was able to provide me with the original data set, Stata DO-File, and the variable descriptions (Shared below with permission from Dr. Depken, be sure to thank him if you use this data).
Now for the problems I’m facing. The original DO-File uses these commands:
sum
reg piracy lninc sfindex salestax unemp yr00 yr01,r
reg piracy lninc unemp statetax sfindex yr00 yr01,r
xtreg piracy lninc unemp statetax sfindex yr00 yr01,fe
xtreg piracy lninc unemp salestax sfindex yr00 yr01,fe
xtreg piracy lninc unemp statetax sfindex yr00 yr01,re
est store random1
xttest0
quiet: xtreg piracy lninc unemp statetax sfindex yr00 yr01,fe
est store fixed1
hausman fixed1 random1
xtreg piracy lninc unemp salestax sfindex yr00 yr01,re
est store random2
xttest0
quiet: xtreg piracy lninc unemp salestax sfindex yr00 yr01,fe
est store fixed2
hausman fixed2 random2
At this point I have created this [R] script based on the commands from the original DO-File:
### Created: March 1, 2011
### Author: Frank Jones
### Last Saved: March 18, 2011
### Piracy Replication
### Generaly good practice to begin R script files with these commands
# clear any objects in memory
rm(list=ls(all=TRUE))
# file location
file.location <- c(“/home/frank/Dropbox/UNC/Spring2011/POLI 784.974/Research Replication/My Work/piracydata-jones.dta”)
# load data
require (foreign)
originalData <- read.dta (file.location, convert.dates=TRUE, convert.factors=TRUE, missing.type=TRUE, convert.underscore=FALSE)
# load packages
install.packages(c(“nlme”,”MASS”))
# run once
library(nlme) # used for computing fixed- and random-effect models (lme4 is an alternative package)
library(MASS) # used for computing robust regression models
# sum
# reg piracy lninc sfindex salestax unemp yr00 yr01,r
reg1 <- rlm(originalData$piracy ~ originalData$lninc + originalData$sfindex + originalData$salestax + originalData$unemp + originalData$yr00 + originalData$yr01)
# reg piracy lninc unemp statetax sfindex yr00 yr01,r
reg2 <- rlm(originalData$piracy ~ originalData$lninc + originalData$unemp + originalData$statetax + originalData$sfindex + originalData$yr00 + originalData$yr01)
# xtreg piracy lninc unemp statetax sfindex yr00 yr01,fe
originalData.Grouped <- groupedData(piracy ~ lninc + unemp + statetax + sfindex + yr00 + yr01 | state, data=originalData) #lme function requires grouped data (grouped here by state)
reg3 <- lme(fixed = piracy ~ lninc + unemp + statetax + sfindex + yr00 + yr01, data = originalData.Grouped)
# xtreg piracy lninc unemp salestax sfindex yr00 yr01,fe
reg4 <- lme(fixed = piracy ~ lninc + unemp + salestax + sfindex + yr00 + yr01, data = originalData.Grouped)
# xtreg piracy lninc unemp statetax sfindex yr00 yr01,re
reg5 <- lme(random = piracy ~ lninc + unemp + statetax + sfindex + yr00 + yr01, data = originalData.Grouped)
# est store random1
# xttest0
# quiet: xtreg piracy lninc unemp statetax sfindex yr00 yr01,fe
# est store fixed1
# hausman fixed1 random1
# xtreg piracy lninc unemp salestax sfindex yr00 yr01,re
# est store random2
# xttest0
# quiet: xtreg piracy lninc unemp salestax sfindex yr00 yr01,fe
# est store fixed2
# hausman fixed2 random2
I am having problems with finding an [R] command which calculates fixed- and random-effect models similar to the xtreg function found in Stata. I’ll post my updated version of this [R] conversion along with the results of my replication once it’s done. Any suggestions for [R] functions that are similar to xtreg are greatly appreciated as well as any other comments you may have about this project.
The Data provided to my by Dr Depken:
My current [R] script:
