Package DBfit. October 25, 2018

Similar documents
Package endogenous. October 29, 2016

Bivariate (Simple) Regression Analysis

Package StVAR. February 11, 2017

Package intccr. September 12, 2017

Package bayesdp. July 10, 2018

Package MARX. June 16, 2017

Package cosinor. February 19, 2015

Package PTE. October 10, 2017

Package ClusterBootstrap

Package MultiRR. October 21, 2015

Package mlvar. August 26, 2018

Package MARX. April 24, 2018

Package bdots. March 12, 2018

Package deming. June 19, 2018

Package DTRreg. August 30, 2017

Package svalues. July 15, 2018

Package glmmml. R topics documented: March 25, Encoding UTF-8 Version Date Title Generalized Linear Models with Clustering

Package PSTR. September 25, 2017

Package bayeslongitudinal

Package texteffect. November 27, 2017

Stat 500 lab notes c Philip M. Dixon, Week 10: Autocorrelated errors

Package EBglmnet. January 30, 2016

Package distdichor. R topics documented: September 24, Type Package

Package lcc. November 16, 2018

Serial Correlation and Heteroscedasticity in Time series Regressions. Econometric (EC3090) - Week 11 Agustín Bénétrix

Lab #13 - Resampling Methods Econ 224 October 23rd, 2018

Package rpst. June 6, 2017

Package SSLASSO. August 28, 2018

Package robustreg. R topics documented: April 27, Version Date Title Robust Regression Functions

Package mlegp. April 15, 2018

Analysis of Panel Data. Third Edition. Cheng Hsiao University of Southern California CAMBRIDGE UNIVERSITY PRESS

Package oaxaca. January 3, Index 11

Package nearfar. June 3, 2017

Package ArCo. November 5, 2017

Package BiDimRegression

Package DSBayes. February 19, 2015

Package gains. September 12, 2017

Package TANDEM. R topics documented: June 15, Type Package

Package simr. April 30, 2018

Package irrna. April 11, 2018

The mblm Package. August 12, License GPL version 2 or newer. confint.mblm. mblm... 3 summary.mblm...

Package esabcv. May 29, 2015

Package MOST. November 9, 2017

Example 1 of panel data : Data for 6 airlines (groups) over 15 years (time periods) Example 1

Package dglm. August 24, 2016

Package gwrr. February 20, 2015

Package ConvergenceClubs

Package epitab. July 4, 2018

Package msgps. February 20, 2015

Package biglars. February 19, 2015

Package survivalmpl. December 11, 2017

Package PCGSE. March 31, 2017

Package apricom. R topics documented: November 24, 2015

STATISTICS (STAT) Statistics (STAT) 1

Package apastyle. March 29, 2017

Annexes : Sorties SAS pour l'exercice 3. Code SAS. libname process 'G:\Enseignements\M2ISN-Series temp\sas\';

Package addhaz. September 26, 2018

Package smicd. September 10, 2018

Package psda. September 5, 2017

Package estprod. May 2, 2018

Package EFS. R topics documented:

Package MIICD. May 27, 2017

Package CausalImpact

Package tpr. R topics documented: February 20, Type Package. Title Temporal Process Regression. Version

Package edrgraphicaltools

Conditional and Unconditional Regression with No Measurement Error

Product Catalog. AcaStat. Software

Package RaPKod. February 5, 2018

Package MSwM. R topics documented: February 19, Type Package Title Fitting Markov Switching Models Version 1.

Two-Stage Least Squares

Package anidom. July 25, 2017

Cross-validation. Cross-validation is a resampling method.

Package edci. May 16, 2018

Package sparsereg. R topics documented: March 10, Type Package

Package mcemglm. November 29, 2015

Conducting a Path Analysis With SPSS/AMOS

Package rfsa. R topics documented: January 10, Type Package

Package assortnet. January 18, 2016

Package ridge. R topics documented: February 15, Title Ridge Regression with automatic selection of the penalty parameter. Version 2.

Robust Linear Regression (Passing- Bablok Median-Slope)

Package rgcvpack. February 20, Index 6. Fitting Thin Plate Smoothing Spline. Fit thin plate splines of any order with user specified knots

Model Diagnostic tests

Package svmpath. R topics documented: August 30, Title The SVM Path Algorithm Date Version Author Trevor Hastie

Package OLScurve. August 29, 2016

Package InformativeCensoring

Package robets. March 6, Type Package

Package qrfactor. February 20, 2015

Package complmrob. October 18, 2015

Package permuco. February 14, Type Package

Package GWRM. R topics documented: July 31, Type Package

Package DTRlearn. April 6, 2018

Package ECctmc. May 1, 2018

Package mtsdi. January 23, 2018

Package nonnest2. January 23, 2018

Package CALIBERrfimpute

Package CepLDA. January 18, 2016

Package vinereg. August 10, 2018

Package longclust. March 18, 2018

SYS 6021 Linear Statistical Models

MS&E 226: Small Data

Transcription:

Type Package Package DBfit October 25, 2018 Title A Double Bootstrap Method for Analyzing Linear Models with Autoregressive Errors Version 1.0 Date 2018-10-16 Author Joseph W. McKean and Shaofeng Zhang Maintainer Shaofeng Zhang <shaofeng.zhang@wmich.edu> Computes the double bootstrap as discussed in McKnight, McKean, and Huitema (2000) <doi:10.1037/1082-989x.5.1.87>. The double bootstrap method provides a better fit for a linear model with autoregressive errors than ARIMA when the sample size is small. License GPL (>= 2) Depends Rfit NeedsCompilation no Repository CRAN Date/Publication 2018-10-24 22:50:03 UTC R topics documented: DBfit-package........................................ 2 boot1............................................ 3 boot2............................................ 4 dbfit............................................. 5 durbin1fit.......................................... 7 durbin1xy.......................................... 8 durbin2fit.......................................... 8 hmdesign2.......................................... 9 hmmat............................................ 10 hypothmat.......................................... 11 lagx............................................. 12 nurho............................................ 12 print.dbfit.......................................... 13 1

2 DBfit-package rhoci2............................................ 13 simpgen1hm2........................................ 14 simula............................................ 15 simulacorrection...................................... 16 summary.dbfit........................................ 17 testdata........................................... 18 wrho............................................. 18 Index 20 DBfit-package A Double Bootstrap Method for Analyzing Linear Models With Autoregressive Errors Computes the double bootstrap as discussed in McKnight, McKean, and Huitema (2000) <doi:10.1037/1082-989x.5.1.87>. The double bootstrap method provides a better fit for a linear model with autoregressive errors than ARIMA when the sample size is small. The DESCRIPTION file: Package: DBfit Type: Package Title: A Double Bootstrap Method for Analyzing Linear Models with Autoregressive Errors Version: 1.0 Date: 2018-10-16 Author: Joseph W. McKean and Shaofeng Zhang Maintainer: Shaofeng Zhang <shaofeng.zhang@wmich.edu> : Computes the double bootstrap as discussed in McKnight, McKean, and Huitema (2000) <doi:10.1037/1082-98 License: GPL (>= 2) Depends: Rfit Index of help topics: DBfit-package A Double Bootstrap Method for Analyzing Linear Models With Autoregressive Errors boot1 First Boostrap Procedure For parameter estimations boot2 First Boostrap Procedure For parameter estimations dbfit The main function for the double bootstrap method durbin1fit Durbin stage 1 fit durbin1xy Creating New X and Y for Durbin Stage 1

boot1 3 durbin2fit Durbin stage 2 fit hmdesign2 the Two-Phase Design Matrix hmmat K-Phase Design Matrix hypothmat General Linear Tests of the regression coefficients lagx Lag Functions nurho Creating a new response variable for Durbin stage 2 print.dbfit DBfit Internal Print Functions rhoci2 A fisher type CI of the autoregressive parameter rho simpgen1hm2 Simulation Data Generating Function simula Work Horse Function to implement the Double Bootstrap method simulacorrection Work Horse Function to Implement the Double Bootstrap Method For.99 Cases summary.dbfit Summarize the double bootstrap (DB) fit testdata testdata wrho Creating a new design matrix for Durbin stage 2 Author(s) Joseph W. McKean and Shaofeng Zhang Maintainer: Shaofeng Zhang <shaofeng.zhang@wmich.edu> McKnight, S. D., McKean, J. W., and Huitema, B. E. (2000). A double bootstrap method to analyze linear models with autoregressive error terms. Psychological methods, 5 (1), 87. Shaofeng Zhang (2017). Ph.D. Dissertation. boot1 First Boostrap Procedure For parameter estimations Function performing the first bootstrap procedure to yield the parameter estimates boot1(y, phi1, arp, nbs, x, allb, method, scores) y phi1 arp the response variable the Durbin two-stage estimate of the autoregressive parameter rho the order of autoregressive errors

4 boot2 nbs x allb method scores the bootstrap size the original design matrix (including intercept), without centering all the Durbin two-stage estimates of the regression coefficients If "OLS", uses the ordinary least square; If "RANK", uses the rank-based fit Default is Wilcoxon scores Value An estimate of the bias is returned Note This function is for internal use. The main function for users is dbfit. boot2 First Boostrap Procedure For parameter estimations Function performing the second bootstrap procedure to yield the inference of the regression coefficients boot2(y, xcopy, phi1, beta, nbs, method, scores) y xcopy phi1 beta nbs method scores the response variable the original design matrix (including intercept), without centering the estimate of the autoregressive parameter rho from the first bootstrap procedure the estimates of the regression coefficients from the first bootstrap procedure the bootstrap size If "OLS", uses the ordinary least square; If "RANK", uses rank-based fit Default is Wilcoxon scores Value betacov allbeta rhostar MSEstar the estimate of var-cov matrix of betas the estimates of betas inside of the second bootstrap, not the final estimates of betas. The final estimates of betas are still from boot1. the estimates of rho inside of the second bootstrap, not the final estimates of rho. The final estimate(s) of rho are still from boot1. MSE used inside of the second bootstrap.

dbfit 5 Note This function is for internal use. The main function for users is dbfit dbfit The main function for the double bootstrap method This function is used to implement the double bootstrap method. It is used to yield estimates of both regression coefficients and autoregressive parameters(rho), and also the inference of them. ## Default S3 method: dbfit(x, y, arp, nbs = 500, nbscov = 500, conf = 0.95, correction = TRUE, method = "OLS", scores,...) x y arp the design matrix, including intercept, i.e. the first column being ones. the response variable. the order of autoregressive errors. nbs the bootstrap size for the first bootstrap procedure. Default is 500. nbscov the bootstrap size for the second bootstrap procedure. Default is 500. conf the confidence level of CI for rho, default is 0.95. correction method scores logical. Currently, ONLY works for order 1, i.e. for order > 1, this correction will not get involved. If TRUE, uses the correction for cases that the estimate of rho is 0.99. Default is TRUE. the method to be used for fitting. If "OLS", uses the ordinary least square lm; If "RANK", uses the rank-based fit rfit. Default is Wilcoxon scores... additional arguments to be passed to fitting routines Computes the double bootstrap as discussed in McKnight, McKean, and Huitema (2000). For details, see the references.

6 dbfit Value coefficients rho1 adjar mse rho_ci_1 rho_ci_2 rho_ci_3 betacov tabbeta the estimates of regression coefficients based on the first bootstrap procedure the Durbin two-stage estimate of the autoregressive parameter rho the estimates of regression coefficients based on the first bootstrap procedure the mean square error the first type of CI for rho, see the second reference for details. the second type of CI for rho, see the second reference for details. the third type of CI for rho, see the second reference for details. the estimate of the variance-covariance matrix of betas a table of point estimates, SE s, test statistics and p-values. flag99 an indicator; if 1, it indicates the original fit yields an estimate of rho to be 0.99. When the correction is requested (default), the correction procedure kicks in, and the final estimates of rho is corrected. Only valid if order 1 is specified. residuals fitted.values Author(s) the residuals, that is response minus fitted values. the fitted mean values. Joseph W. McKean and Shaofeng Zhang McKnight, S. D., McKean, J. W., and Huitema, B. E. (2000). A double bootstrap method to analyze linear models with autoregressive error terms. Psychological methods, 5 (1), 87. See Also Shaofeng Zhang (2017). Ph.D. Dissertation. dbfit.formula Examples # make sure the dependent package Rfit is installed # To save users time, we set both bootstrap sizes to be 100 in this example. # Defaults are both 500. data(testdata) # This data is generated by a two-phase design, with autoregressive order being one, # autoregressive coefficient being 0.6 and all regression coefficients being 0. # Both the first and second phase have 20 observations. y <- testdata[,5] x <- testdata[,1:4] fit1 <- dbfit(x,y,1, nbs = 100, nbscov = 100) # OLS fit, default summary(fit1) # Note that the CI's of autoregressive coef are not shown in the summary.

durbin1fit 7 # Instead, they are attributes of model fit. fit1$rho_ci_1 # fit2 <- dbfit(x,y,1, nbs = 100, nbscov = 100,method="RANK") # rank-based fit # When fitting with autoregressive order 2, # the estimate of the second order autoregressive coefficient should not be significant, # since this data is generated with order 1. # fit3 <- dbfit(x,y,2, nbs = 100, nbscov = 100) # fit3$rho_ci_1 # The first row is lower bounds, and second row is upper bounds durbin1fit Durbin stage 1 fit Function implements the Durbin stage 1 fit durbin1fit(y, x, arp, method, scores) y x arp method scores the response variable in stage 1, not the original response variable the model matrix in stage 1, not the original design matrix the order of autoregressive errors. the method to be used for fitting. If "OLS", uses the ordinary least square; If "RANK", uses the rank-based fit. Default is Wilcoxon scores Note This function is for internal use. The main function for users is dbfit. McKnight, S. D., McKean, J. W., and Huitema, B. E. (2000). A double bootstrap method to analyze linear models with autoregressive error terms. Psychological methods, 5 (1), 87. Shaofeng Zhang (2017). Ph.D. Dissertation.

8 durbin2fit durbin1xy Creating New X and Y for Durbin Stage 1 Functions provides the tranformed reponse variable and model matrix for Durbin stage 1 fit. For details of the transformation, see the reference. durbin1xy(y, x, arp) y x arp the orginal response variable the orginal design matrix with first column of all one s (corresponding to the intercept) the order of autoregressive errors. McKnight, S. D., McKean, J. W., and Huitema, B. E. (2000). A double bootstrap method to analyze linear models with autoregressive error terms. Psychological methods, 5 (1), 87. Shaofeng Zhang (2017). Ph.D. Dissertation. durbin2fit Durbin stage 2 fit Function implements the Durbin stage 1 fit durbin2fit(yc, xc, adjphi, method, scores) yc xc adjphi method scores a transformed reponse variable a transformed design matrix the Durbin stage 1 estimate(s) of the autoregressive parameters rho the method to be used for fitting. If "OLS", uses the ordinary least square; If "RANK", uses the rank-based fit. Default is Wilcoxon scores

hmdesign2 9 Value beta sigma the estimates of regression coefficients the estimate of standard deviation of the white noise Note This function is for internal use. The main function for users is dbfit. McKnight, S. D., McKean, J. W., and Huitema, B. E. (2000). A double bootstrap method to analyze linear models with autoregressive error terms. Psychological methods, 5 (1), 87. Shaofeng Zhang (2017). Ph.D. Dissertation. hmdesign2 the Two-Phase Design Matrix Returns the design matrix for a two-phase intervention model. hmdesign2(n1, n2) n1 number of obs in phase 1 n2 number of obs in phase 2 It returns a matrix of 4 columns. As discussed in Huitema, Mckean, & Mcknight (1999), in twophase design: beta0 = intercept, beta1 = slope for Phase 1, beta2 = level change from Phase 1 to Phase 2, and beta3 slope change from Phase 1 to Phase 2. Huitema, B. E., Mckean, J. W., & Mcknight, S. (1999). Autocorrelation effects on least- squares intervention analysis of short time series. Educational and Psychological Measurement, 59 (5), 767-786. Examples n1 <- 15 n2 <- 15 hmdesign2(n1, n2)

10 hmmat hmmat K-Phase Design Matrix Returns the design matrix for a general k-phase intervention model hmmat(vecss, k) vecss k a vector of length k with each element being the number of observations in each phase number of phases It returns a matrix of 2*k columns. The design can be unbalanced, i.e. each phase has different observations. Huitema, B. E., Mckean, J. W., & Mcknight, S. (1999). Autocorrelation effects on least- squares intervention analysis of short time series. Educational and Psychological Measurement, 59 (5), 767-786. See Also hmdesign2 Examples # a three-phase design matrix hmmat(c(10,10,10),3)

hypothmat 11 hypothmat General Linear Tests of the regression coefficients Performs general linear tests of the regressio coefficients. hypothmat(sfit, mmat, n, p) sfit mmat n p the result of a call to dbfit. a full row rank q*(p+1) matrix, where q is the row number of the matrix and p is number of independent variables. total number of observations. number of independent variables. This functions performs the general linear F-test of the form H0: Mb = 0 vs HA: Mb!= 0. Value tst pvf the test statistic the p-value of the F-test McKnight, S. D., McKean, J. W., and Huitema, B. E. (2000). A double bootstrap method to analyze linear models with autoregressive error terms. Psychological methods, 5 (1), 87. Shaofeng Zhang (2017). Ph.D. Dissertation. Examples data(testdata) y<-testdata[,5] x<-testdata[,1:4] fit1<-dbfit(x,y,1) # OLS fit, default # a test that H0: b1 = b3 vs HA: b1!= b3 mat<-matrix(c(1,0,0,-1),nrow=1) hypothmat(sfit=fit1,mmat=mat,n=40,p=4)

12 nurho lagx Lag Functions For preparing the transformed x and y in the Durbin stage 1 fit lagx(x, s1, s2) lagmat(x, p) x s1 s2 p a vector or the design matrix, including intercept, i.e. the first column being ones. starting index of the slice. end index of the slice. the order of autoregressive errors. Note These function are for internal use. nurho Creating a new response variable for Durbin stage 2 It returns a new response variable (vector) for Durbin stage 2. nurho(yc, adjphi) yc the centered response variable y adjphi (initial) estimate of rho in Durbin stage 1 see reference.

print.dbfit 13 Note This function is for internal use. The main function for users is dbfit. McKnight, S. D., McKean, J. W., and Huitema, B. E. (2000). A double bootstrap method to analyze linear models with autoregressive error terms. Psychological methods, 5 (1), 87. Shaofeng Zhang (2017). Ph.D. Dissertation. print.dbfit DBfit Internal Print Functions These functions print the output in a user-friendly manner using the internal R function print. ## S3 method for class 'dbfit' print(x,...) ## S3 method for class 'summary.dbfit' print(x,...) x An object to be printed... additional arguments to be passed to print See Also dbfit, summary.dbfit rhoci2 A fisher type CI of the autoregressive parameter rho This function returns a Fisher type CI for rho, which is then used to correct the.99 cases. rhoci2(n, rho, cv)

14 simpgen1hm2 n total number of observations rho final estimate of rho, usually.99. cv Note see reference. critical value for CI This function is for internal use. Shaofeng Zhang (2017). Ph.D. Dissertation. Rao, C. R. (1952). Advanced statistical methods in biometric research. p. 231 simpgen1hm2 Simulation Data Generating Function Generates the simulation data for a two-phase intervention model. simpgen1hm2(n1, n2, rho, beta = c(0, 0, 0, 0)) n1 number of obs in phase 1 n2 number of obs in phase 2 rho beta Value pre-defined autoregressive parameter(s) pre-defined regression coefficients This function is used for simulations when developing the package. With pre-defined sample sizes in both phases and parameters, it returns a simulated data. mat a matrix containing the simulation data. The last column is the response variable. All other columns make up the design matrix.

simula 15 See Also hmdesign2 Examples n1 <- 15 n2 <- 15 rho <- 0.6 beta <- c(0,0,0,0) dat <- simpgen1hm2(n1, n2, rho, beta) dat simula Work Horse Function to implement the Double Bootstrap method simula is the original work horse function to implement the DB method. However, when this function returns an estimate of rho to be.99, another work horse function simulacorrection kicks in. simula(x, y, arp, nbs, nbscov, conf, method, scores) x y arp the design matrix, including intercept, i.e. the first column being ones. the response variable. the order of autoregressive errors. nbs the bootstrap size for the first bootstrap procedure. Default is 500. nbscov the bootstrap size for the second bootstrap procedure. Default is 500. conf the confidence level of CI for rho, default is 0.95. method scores see dbfit. the method to be used for fitting. If "OLS", uses the ordinary least square lm; If "RANK", uses the rank-based fit rfit. Default is Wilcoxon scores Note Users should use dbfit to perform the analysis.

16 simulacorrection McKnight, S. D., McKean, J. W., and Huitema, B. E. (2000). A double bootstrap method to analyze linear models with autoregressive error terms. Psychological methods, 5 (1), 87. Shaofeng Zhang (2017). Ph.D. Dissertation. See Also dbfit. simulacorrection Work Horse Function to Implement the Double Bootstrap Method For.99 Cases When function simula returns an estimate of rho to be.99, this function kicks in and ouputs a corrected estimate of rho. Currently, this only works for order 1, i.e. for order > 1, this correction will not get involved. simulacorrection(x, y, arp, nbs, nbscov, method, scores) x y arp the design matrix, including intercept, i.e. the first column being ones. the response variable. the order of autoregressive errors. nbs the bootstrap size for the first bootstrap procedure. Default is 500. nbscov the bootstrap size for the second bootstrap procedure. Default is 500. method scores the method to be used for fitting. If "OLS", uses the ordinary least square lm; If "RANK", uses the rank-based fit rfit. Default is Wilcoxon scores If 0.99 problem is detected, then construct Fisher CI for both initial estimate (in Durbin stage 1) and first bias-corrected estimate (perform only one bootstrap, instead of a loop); if the midpoint of latter is smaller than 0.95, then this midpoint is the final estimate for rho; otherwise the midpoint of the former CI is the final estimate. By default, when function simula returns an estimate of rho to be.99, this function kicks in and ouputs a corrected estimate of rho. However, users can turn the auto correction off by setting correction="false" in dbfit. Users are encouraged to investigate why the stationarity assumption is violated based on their experience of time series analysis and knowledge of the data.

summary.dbfit 17 Note Users should use dbfit to perform the analysis. Shaofeng Zhang (2017). Ph.D. Dissertation. See Also dbfit. summary.dbfit Summarize the double bootstrap (DB) fit It summarizes the DB fit in a way that is similar to OLS lm. ## S3 method for class 'dbfit' summary(object,...) Value object a result of the call to rfit... additional arguments to be passed call tab rho1 adjar the call to rfit a table of point estimates, standard errors, t-ratios and p-values the Durbin two-stage estimate of rho the DB (final) estimate of rho flag99 an indicator; if 1, it indicates the original fit yields an estimate of rho to be 0.99. Only valid if order 1 is specified. Examples data(testdata) y<-testdata[,5] x<-testdata[,1:4] fit1<-dbfit(x,y,1) # OLS fit, default summary(fit1)

18 wrho testdata testdata This data serves as a test data. data("testdata") Format A data frame with 40 observations. First 4 columns make up the design matrix, while the last column is the response variable. This data is generated by a two-phase design, with autoregressive order being one, autoregressive coefficient being 0.6 and all regression coefficients being 0. Both the first and second phase have 20 observations. Examples data(testdata) wrho Creating a new design matrix for Durbin stage 2 It returns a new design matrix for Durbin stage 2. wrho(xc, adjphi) xc centered design matrix, no column of ones adjphi (initial) estimate of rho in Durbin stage 1 see reference. Note This function is for internal use. The main function for users is dbfit.

wrho 19 McKnight, S. D., McKean, J. W., and Huitema, B. E. (2000). A double bootstrap method to analyze linear models with autoregressive error terms. Psychological methods, 5 (1), 87. Shaofeng Zhang (2017). Ph.D. Dissertation.

Index Topic datasets testdata, 18 boot1, 3 boot2, 4 DBfit (DBfit-package), 2 dbfit, 5, 13, 15 17 DBfit-package, 2 durbin1fit, 7 durbin1xy, 8 durbin2fit, 8 hmdesign2, 9, 10, 15 hmmat, 10 hypothmat, 11 lagmat (lagx), 12 lagx, 12 nurho, 12 print.dbfit, 13 print.summary.dbfit (print.dbfit), 13 rhoci2, 13 simpgen1hm2, 14 simula, 15 simulacorrection, 16 summary.dbfit, 13, 17 testdata, 18 wrho, 18 20