Package REGARMA October 1, 2014 Type Package Title Regularized estimation of Lasso, adaptive lasso, elastic net and REGARMA Version 0.1.1.1 Date 2014-10-01 Depends R(>= 2.10.0) Imports tseries, msgps Author Hamed Haselimashhadi (www.hamedhaseli.webs.com) Maintainer Hamed Haseli <hamed.haselimashhadi@brunel.ac.uk>, <hamedhaseli@gmail.com> This package estimates Lasso, adaptive Lasso, elastic net and REGARMA regression using AIC, BIC and GCV. License GPL (>= 2) LazyLoad no Repository CRAN Date/Publication 2014-10-01 11:21:29 NeedsCompilation yes R topics documented: REGARMA-package.................................... 2 generatear......................................... 2 naics5809.......................................... 3 regarma.......................................... 4 sim.regarma....................................... 6 Index 8 1
2 generatear REGARMA-package Regularized estimation of a REGARMA model. Details This packages provides functions to fit an autoregressive moving average model with time-dependent predictors (REGARMA) using a penalised likelihood approach under AIC, BIC or GCV model selection criteria. Package: REGARMA Type: Package Version: 0.2-5 Date: 2014-01-15 License: GPL2 or newer LazyLoad: yes Author(s) Hamed Haselimashhadi <hamed.haselimashhadi@brunel.ac.uk>, Veronica Vinciotti <veronica.vinciotti@brunel.ac.uk> R. Tibshirani (1996), "Regression shrinkage and selection via the lasso", Journal of the Royal Statistical Society. Series B, 267-288. H. Wang, G. Li, C. Tsai (2007), "Regression coefficient and autoregressive order shrinkage and selection via the lasso", Journal of the Royal Statistical Society. Series B, 69, 63-78. H. Zou (2006), "The adaptive lasso and its oracle properties", Journal of the American statistical association, 476, 1418-1429. Haselimashhadi, H. and Vinciotti, V. (2014) Penalised estimation of autoregressive moving average models with time-dependent predictors. Submitted. generatear A function to generate autoregressive coefficients A function to generate autoregressive coefficients in a certain interval and with a mimum distance amongst any two coefficients. Usage generatear(n = 1, l = -1, u = 1, min.distance =.Machine$double.eps)
naics5809 3 Arguments n l u min.distance The number of coefficients Lower bound of coefficients Upper bound of coefficients Minimum distance among each two coefficients Author(s) Hamed Haselimashhadi <hamed.haselimashhadi@brunel.ac.uk> Haselimashhadi, H. and Vinciotti, V. (2014) Penalised estimation of autoregressive moving average models with time-dependent predictors (Working Paper). Brunel University London, UK See Also regarma Examples generatear(5,-1,1,.01) naics5809 NBER-CES Manufacturing Industry Database(1958-2009) Usage Format This database is a joint effort between the National Bureau of Economic Research (NBER) and U.S. Census Bureau s Center for Economic Studies (CES), containing annual industry-level data from 1958-2009 on output, employment, payroll and other input costs, investment, capital stocks, TFP, and various industry-specific price indexes. data(naics5809) A data frame with 23868 observations on the following 24 variables. sic : NAICS 4-digit Codes year : Year ranges from 1958 to 2009 emp : Total employment in 1000s pay : Total payroll in $1m prode : Production workers in 1000s prodh : Production worker hours in 1m prodw : Production worker wages in $1m vship : Total value of shipments in $1m
4 regarma matcost : Total cost of materials in $1m vadd : Total value added in $1m invest : Total capital expenditure in $1m invent : End-of-year inventories in $1m energy : Cost of electricity & fuels in $1m cap : Total real capital stock in $1m equip : Real capital: equipment in $1m plant : Real capital: structures in $1m piship : Deflator for VSHIP 1997=1.000 pimat : Deflator for MATCOST 1997=1.000 piinv : Deflator for INVEST 1997=1.000 pien : Deflator for ENERGY 1997=1.000 dtfp5 : 5-factor TFP annual growth rate tfp5 : 5-factor TFP index 1997=1.000 dtfp4 : 4-factor TFP annual growth rate tfp4 : 4-factor TFP index 1997=1.000 Source http://www.nber.org/nberces/ Official website: http://www.nber.org/data/nberces5809.html Variable description and summary statistics: http://www.nber.org/nberces/nberces5809/nberces_ 5809_summary_stats.pdf Updated documentation: http://www.nber.org/nberces/nberces5809/nberces_5809_technical_ notes.pdf Examples data(naics5809) str(naics5809) regarma A function for penalised estimation of a REGARMA model from timeseries regression data. This function estimates the parameters of a REGARMA model using lasso and adaptive lasso penalties for a given dataset with or without replications. It also selects the optimal model using AIC, BIC and GCV.
regarma 5 Usage regarma(data, ar = 0, ma = 0, method = c("alasso"), mselection = "BIC", alpha = 0, Ndf = 0, Sdf = 0, normalize = FALSE, auto.order = FALSE, debug = FALSE) Arguments data ar ma method mselection alpha Ndf Sdf normalize auto.order debug Raw data of the form of a matrix. The first column should contain ids of replications. Note that the points belonging to each replication id must be sorted with respect to time. The second column should contain the response variable (y), the remaining columns should contain the predictors (x). In the case of no replication, the first column should be simply 1:T, with T the number of time points. AR order of model MA order of model Type of penalties. Choose between elastic net (enet) and adaptive lasso (alasso). Note that lasso can be computed by choosing enet for method and setting alpha equals to zero. Model selection criteria. Choose between AIC, BIC and GCV for the selection of the tuning parameters. Weight in elastic net. Degree of differencing if necessary Degree of seasonal differencing if necessary Set to TRUE in order to normalize the data to mean zero and unit variance If TRUE, the optimal orders of the model are chosen according to AIC (if mselection="aic") or BIC (if mselection="bic" or "GCV"). To see a detailed report of process set this parameter to TRUE. Details More details about the parameter estimation approach are given in Haselimashhadi and Vinciotti (2014). Author(s) Hamed Haselimashhadi <hamed.haselimashhadi@brunel.ac.uk> Haselimashhadi, H. and Vinciotti, V. (2014) Penalised estimation of autoregressive moving average models with time-dependent predictors (Working Paper). Brunel University London, UK See Also sim.regarma
6 sim.regarma Examples # --------------- FIRST EXAMPLE: regarma without replications ----------------# # True regression coefficients beta=c(1:6,rep(0,200)) # Simulating data (100 time points) simdata=sim.regarma(n=100,beta=beta,phi=generatear(2,min.distance =.3),theta=generateAR(1), x.independent=true,var.error=.1) #Fitting a REGARMA(2,1) model regarma.fit=regarma(data = simdata$rawdata,ar = 2,ma = 1,method = 'alasso', mselection = 'BIC') #Printing true and estimated coefficients cat('coefficients:',beta[1:6],',0,..., ',0) print(round(as.vector(regarma.fit$betas),2)) print('-------------- OUTPUT structure --------------') str(regarma.fit) cat ("Press [enter] to see the second example");line <- readline() # ----------------------- SECOND EXAMPLE: regarma with replications ------------------------# data(naics5809) R=10;dif1=2;dif2=0;ar=2;ma=1 # Select the first 10 ids. 52 time points are available for each id # Note that naics5809 contains two response variables namely, emp and pay. The analysis below considers pay fo # Data are sorted for each id (based on time). data=as.matrix(naics5809)[1:(52*r),-(2:3)] data[is.na(data)==true]=0 # ----------------------- Fitting model ------------------------# regarma.fit=regarma(data=data,ar=ar,ma=ma,method='alasso',ndf=dif1,sdf=dif2) # ----------------------- Printing outputs ------------------------# print('-------------- OUTPUT structure --------------') str(regarma.fit) sim.regarma A function to simulate data from a REGARMA model This function simulates a Gaussian lagged regression variable in the presence of autocorrelation among residuals (REGARMA) Usage sim.regarma(n = 5, beta = c(0.62), x.independent = TRUE, phi = c(0.3), theta = c(0.5), var.error = 1, draw.plot = FALSE)
sim.regarma 7 Arguments n beta x.independent phi theta var.error draw.plot The number of datapoints to be simulated Regression coefficients * Note that coefficients must be in [-1,1] for time-series data (x.independent=false). Set this option to true if regression variables are assumed to be independent Autoregressive coefficients * Note that, for stationarity, all roots of the polynomial must site outside of a unit circle Residuals coefficients * Note that, for stationarity, all roots of the polynomial include coefficients must site outside of a unit circle Variance of the process If TRUE, a time series plot is drawn Author(s) Hamed Haselimashhadi <hamed.haselimashhadi@brunel.ac.u> Haselimashhadi, H. and Vinciotti, V. (2014) Penalised estimation of autoregressive moving average models with time-dependent predictors (Working Paper). Brunel University London, UK See Also regarma Examples simdata=sim.regarma(n = 100,beta =.1,x.independent = TRUE,phi =.4, theta = -.4,var.error = 1,draw.plot = TRUE) str(simdata)
Index Topic \textasciitildekwd1 generatear, 2 regarma, 4 sim.regarma, 6 Topic \textasciitildekwd2 generatear, 2 regarma, 4 sim.regarma, 6 Topic datasets naics5809, 3 Topic package REGARMA-package, 2 generatear, 2 naics5809, 3 REGARMA (REGARMA-package), 2 regarma, 3, 4, 7 REGARMA-package, 2 sim.regarma, 5, 6 8