readme.txt

These files are distributed to compute the Mallows Model Average (MMA) 
and the Jackknife Model Average (JMA) least-squares estimates.
 

written by:

Bruce E. Hansen

Department of Economics
Social Science Building
University of Wisconsin
Madison, WI 53706-1393
behansen@wisc.edu
http://www.ssc.wisc.edu/~bhansen/



The files are

gma.DO
rungma.R
rsource.ado
rsource.sthlp


(1) gma.DO 
This is a stata do file. It runs the R source file rungma.R inside Stata.
The procedure takes the form:

     run "Z:\\rsource.ado"

     global Rterm_path `"c:\Program Files\R\R-2.12.0\bin\i386\Rterm.exe"'

     global Rterm_options `"--vanilla"'

     rsource using "Z:\\rungma.R" 

      
(2) rungma.R 
This is a R procedure. It computes the Mallows Model Average (MMA) 
and the Jackknife Model Average (JMA) least-squares estimates.
The procedure takes the form:

     library(foreign)

     library(quadprog) 

     xy <- read.dta("Z:\\data_filename.dta")

     y <- xy[,1]

     x <- xy[,2:ncol(xy)]

     method <- 2

     subset <- 2


(3) rsource.ado
This is a stata ado file distributed by Roger Newson (2008). It runs R from 
inside Stata using an R source file and lists the output to the Stata log.

(4) rsource.sthlp
This is a stata help file for rsource.ado distributed by Roger Newson (2008). 


Step by step instructions:

(1) Install the R software.
    Download the R statistical software from the R project website. 
    http://www.r-project.org/
    After installing R, run the following command in R first: 
    install.packages("quadprog")


(2) Create the data set.
    The data set file should only contain the dependent variable (y) and regressors (x) 
    with the dependent variable in the first column, the intercept in the second column, 
    and the regressors in the remaining columns. The data set is read from the R source 
    file rungma.R by the following command:
       
         xy <- read.dta("Z:\\data_filename.dta")
    
    Make sure to change the file name and file paths of the data set in the rungma.R file.


(4) Modify the parameters in the rungma.R file. 
    There are two control parameters, method and subset, governing the choice of the 
    method used to compute the averaging estimtor and the subsets. These controls are 
    listed at the beginning of the procedure code. The default value of the method is 
    Jackknife model average estimates and the default value of the subset is all 
    combinations of subsets. 
    

(5) Modify the R path in the gma.DO file.
    Make sure the global Rterm_path is correct. The user should change the global Rterm_path 
    if the user downloads a new version of R or the R path is not set to its correct value. 
    (See Technical note in help file for rsource.)


(6) Run gma.DO in Stata.
    After running gma.DO, the R output is listed to the Stata results window. Also, the 
    results of the parameter estimate and the weight vector are saved in two files, 
    betahat.dat and weight.dat.


