Simulation Experiment, AR(1)

Introduction and Initializations

In this notebook the asymptotic power is compared with the empirical power as determined by simulation for the AR(1) case.  Both the Z-test and the likelihood-ratio test are examined.  The parameters used are discussed below.

The number of simulations,

NSIM = 1000;

The size of the test,

α = 0.05;

The parameters in the AR(1) model

phis = {-0.75, -0.5, -0.25, 0.0, 0.25, 0.5, 
          0.75};

The parameters for the step intervention change, δ  = ω/sd(ω)

deltas = Range[-2.0, 2.0, 0.25];

Output from the simulations are saved in the directory below.  This may be need to be changed.

outDirectory = "c:/p/2003/tex/Technometrics/simulations";

Other Initializations

totTime = 0;

phisTitle = StyleForm[StringJoin["ϕ=", ToString[#]], 
              FontColor -> RGBColor[0, 0, 1], 
              FontWeight -> "Bold"] & /@ phis;

thetasTitle = StyleForm[StringJoin["θ=", ToString[#]], 
              FontColor -> RGBColor[0, 0, 1], 
              FontWeight -> "Bold"] & /@ thetas;

deltasTitle = StyleForm[StringJoin["δ=", ToString[#]], 
              FontColor -> RGBColor[0, 0, 1], 
              FontWeight -> "Bold"] & /@ deltas;

Basic simulation functions for AR(1) and IMA(1) IA models are provided by our notebook iapower.m

<< c:/p/2003/tex/technometrics/simulations/iapower.m

<< Statistics`ContinuousDistributions`

Options[Getβ]

?Getβ

?Plotβ

AR(1) with Design I:  T=25, n=50

Z-Test

T = 25; n = 50; SeedRandom[232341];

Test out with NSIM=100, ϕ=0.5, δ=1

Getβ[T, n, α, 0.5, 1, 10]

Getβ[T, n, α, 0.5, 1, 10,  
      Tail -> "TwoSided"]

Main Simulation

Timing[
      mergedTable2SZA = 
        Table[PowerZTest /. 
            Getβ[T, n, α, 
              phis[[i]], 
              deltas[[j]], NSIM,  
              Tail -> "TwoSided"], {j, Length[deltas]}, {i, 
            Length[phis]}]]

totTime = +First[%];

TableForm[mergedTable2SZA, 
      TableHeadings -> {deltasTitle, phisTitle}]

Save AR Data

outFile = outDirectory <> "/ar1Z.dat";

DeleteFile[outFile]

Save[outFile, {mergedTable2SZA}]

Load Data and Do Graphs, Z-test

outFile = outDirectory <> "/ar1Z.dat";

Get[outFile];

Z test

x = mergedTable2SZA;
\(\(gARZ = 
        Table[T = 25; n = 50; 

          est = Table[
              x[[i, j]], {i, 
                Length[deltas]}]; 
estSd = Sqrt[est*\((1 - est)\)/NSIM]; 

          em = Transpose[{est, estSd}]; 

          Plotβ[em, deltas, T, n, 0.05, 
            phis[[j]], 0, \ 
            Tail -> "TwoSided"], {j, Length[phis]}];\)\)

Likelihood-ratio Test

T = 25; n = 50; SeedRandom[232341];

Test out with NSIM=100, ϕ=0.5, δ=1

Getβ[T, n, α, 0.5, 1, 10]

Getβ[T, n, α, 0.5, 1, 10,  Tail -> "TwoSided", 
      TestType -> "LR"]

Main Simulation

Timing[
      mergedTable2SLRA = 
        Table[PowerLRTest /. 
            Getβ[T, n, α, 
              phis[[i]], 
              deltas[[j]], NSIM,  
              Tail -> "TwoSided", TestType -> "LR"], {j, 
            Length[deltas]}, {i, Length[phis]}]]

totTime += First[%];

TableForm[mergedTable2SLRA, 
      TableHeadings -> {deltasTitle, phisTitle}]

Save AR Data

outFile = outDirectory <> "/ar1LR.dat";

DeleteFile[outFile]

Save[outFile, {mergedTable2SLRA}]

Load Data and Do Graphs, Likelihood-Ratio Test

outFile = outDirectory <> "/ar1LR.dat";

Get[outFile];

Z test

x = mergedTable2SLRA;
\(\(gAR60LR = 
        Table[T = 25; n = 50; 

          est = Table[
              x[[i, j]], {i, 
                Length[deltas]}]; 
estSd = Sqrt[est*\((1 - est)\)/NSIM]; 

          em = Transpose[{est, estSd}]; 

          Plotβ[em, deltas, T, n, 0.05, 
            phis[[j]], 0, \ 
            Tail -> "TwoSided"], {j, Length[phis]}];\)\)