AR(1) Concentrated Loglikelihood

Definition

(Subscript[z, t]) = μ + ϕ ((Subscript[z, t - 1]) - μ) + 
        (Subscript[a, t])

L(ϕ) = -(n/2) log(S/n) - 
        (Subscript[g, n])

where (Subscript[g, n]) = 1 - (ϕ^2) and

\(TraditionalForm\`S = \(\((z\_1 - μ)\)\^2\) \((1 - ϕ\^2)\) + ∑\+\(t = 2\)\%n\( a\&^\)\_t\%2\)

where \(TraditionalForm\`\(a\&^\)\_t = \((z\_t - μ)\) - ϕ(
            z\_\(t - 1\) - μ)\)

Implementation

logLLAR1[phi_,  z_] := 
      Module[{w = z - Mean[z], n = Length[z], a, S, 
          g}, 
a = Array[0.0 &, n]; 
Do[
          a[[t]] = 
            w[[t]] - 
              phi*w[[t - 1]], {t, 2, 
            n}]; 
a[[1]] = 
          w[[1]]*
            Sqrt[(1 - (phi^2))]; 
S = 
          Total[(a^2)]; 
g = -Log[
              1 - (phi^2)]; 
SSAR = S; 
        gAR = g; 
-(n/2) Log[S/n] - g/2]

Validation

Initialization

<< TrenchInverse.m

<< FitARMA.m

SeedRandom[2317781]

Example

phi = {0.7}; theta = {}; n = 100;

z = SimulateGaussianAR[phi, n];
w = z - Mean[z];

logLLAR1[phi // First,  w]

r = TacvfARMA[phi, theta, Length[z] - 1];

TrenchLoglikelihood[r, w]

LoglikelihoodAR[phi, w]

DLLoglikelihood[r, w]

g0 = First[r]; r = r/g0;

?TrenchQFM

{s, lg, err} = ans = TrenchQFM[r, w, $MachineEpsilon]

-(n/2) Log[s/n] - lg/2