<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import numpy as np <EOL> from numpy . testing import assert_almost_equal <EOL> import matplotlib . pyplot as plt <EOL> import numdifftools as ndt <EOL> import statsmodels . api as sm <EOL> from statsmodels . sandbox import tsa <EOL> from statsmodels . tsa . arma_mle import Arma <EOL> from statsmodels . tsa . arima_process import arma_generate_sample <EOL> examples = [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in examples : <EOL> print ( "<STR_LIT>" ) <EOL> print ( '<STR_LIT>' ) <EOL> ar = [ <NUM_LIT:1.0> , - <NUM_LIT> ] <EOL> ma = [ <NUM_LIT:1.0> , <NUM_LIT:0.5> ] <EOL> y1 = arma_generate_sample ( ar , ma , <NUM_LIT:1000> , <NUM_LIT:0.1> ) <EOL> y1 -= y1 . mean ( ) <EOL> arma1 = Arma ( y1 ) <EOL> arma1 . nar = <NUM_LIT:1> <EOL> arma1 . nma = <NUM_LIT:1> <EOL> arma1res = arma1 . fit_mle ( order = ( <NUM_LIT:1> , <NUM_LIT:1> ) , method = '<STR_LIT>' ) <EOL> print ( arma1res . params ) <EOL> arma2 = Arma ( y1 ) <EOL> arma2 . nar = <NUM_LIT:1> <EOL> arma2 . nma = <NUM_LIT:1> <EOL> res2 = arma2 . fit ( method = '<STR_LIT>' ) <EOL> print ( res2 . params ) <EOL> print ( res2 . model . hessian ( res2 . params ) ) <EOL> print ( ndt . Hessian ( arma1 . loglike , stepMax = <NUM_LIT> ) ( res2 . params ) ) <EOL> arest = tsa . arima . ARIMA ( y1 ) <EOL> resls = arest . fit ( ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> print ( resls [ <NUM_LIT:0> ] ) <EOL> print ( resls [ <NUM_LIT:1> ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( [ - <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT:0.1> ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( arma1res . params ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( res2 . params ) <EOL> print ( '<STR_LIT>' ) <EOL> errls = arest . error_estimate <EOL> print ( resls [ <NUM_LIT:0> ] , np . sqrt ( np . dot ( errls , errls ) / errls . shape [ <NUM_LIT:0> ] ) ) <EOL> err = arma1 . geterrors ( res2 . params ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( np . dot ( errls , errls ) / errls . shape [ <NUM_LIT:0> ] * resls [ <NUM_LIT:1> ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( res2 . model . optimresults [ '<STR_LIT>' ] [ : <NUM_LIT:2> , : <NUM_LIT:2> ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( - np . linalg . inv ( ndt . Hessian ( arma1 . loglike , stepMax = <NUM_LIT> ) ( res2 . params ) ) [ : <NUM_LIT:2> , : <NUM_LIT:2> ] ) <EOL> print ( '<STR_LIT>' ) <EOL> arma3 = Arma ( y1 ** <NUM_LIT:2> ) <EOL> res3 = arma3 . fit ( method = '<STR_LIT>' ) <EOL> print ( res3 . params ) <EOL> print ( '<STR_LIT>' ) <EOL> arma4 = Arma ( y1 ) <EOL> arma4 . nar = <NUM_LIT:3> <EOL> arma4 . nma = <NUM_LIT:3> <EOL> res4 = arma4 . fit ( start_params = [ - <NUM_LIT:0.5> , - <NUM_LIT:0.1> , - <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:0.1> , <NUM_LIT:0.5> ] ) <EOL> print ( res4 . params ) <EOL> print ( '<STR_LIT>' ) <EOL> pcov = - np . linalg . inv ( ndt . Hessian ( arma4 . loglike , stepMax = <NUM_LIT> ) ( res4 . params ) ) <EOL> print ( '<STR_LIT>' ) <EOL> pstd = np . sqrt ( np . diag ( pcov ) ) <EOL> print ( pstd ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( res4 . params / pstd ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( np . linalg . eigh ( pcov ) [ <NUM_LIT:0> ] ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( '<STR_LIT>' ) <EOL> ar = [ <NUM_LIT:1.0> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT:0.1> ] <EOL> ma = [ <NUM_LIT:1.0> , <NUM_LIT:0.5> , <NUM_LIT:0.1> , <NUM_LIT:0.1> ] <EOL> y2 = arest . generate_sample ( ar , ma , <NUM_LIT:1000> , <NUM_LIT:0.1> ) <EOL> y2 -= y2 . mean ( ) <EOL> print ( '<STR_LIT>' ) <EOL> arma4 = Arma ( y2 ) <EOL> arma4 . nar = <NUM_LIT:3> <EOL> arma4 . nma = <NUM_LIT:3> <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' , ar [ <NUM_LIT:1> : ] ) <EOL> print ( '<STR_LIT>' , ma [ <NUM_LIT:1> : ] ) <EOL> res4 = arma4 . fit ( start_params = [ - <NUM_LIT:0.5> , - <NUM_LIT:0.1> , - <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:0.1> , <NUM_LIT:0.5> ] ) <EOL> print ( res4 . params ) <EOL> print ( '<STR_LIT>' ) <EOL> pcov = - np . linalg . inv ( ndt . Hessian ( arma4 . loglike , stepMax = <NUM_LIT> ) ( res4 . params ) ) <EOL> print ( '<STR_LIT>' ) <EOL> pstd = np . sqrt ( np . diag ( pcov ) ) <EOL> print ( pstd ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( res4 . params / pstd ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( np . linalg . eigh ( pcov ) [ <NUM_LIT:0> ] ) <EOL> print ( '<STR_LIT>' ) <EOL> arma6 = Arma ( y2 ) <EOL> arma6 . nar = <NUM_LIT:3> <EOL> arma6 . nma = <NUM_LIT:3> <EOL> res6 = arma6 . fit ( start_params = [ - <NUM_LIT:0.5> , - <NUM_LIT:0.1> , - <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:0.1> , <NUM_LIT:0.5> ] , <EOL> method = '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( res6 . params ) <EOL> print ( '<STR_LIT>' ) <EOL> hopt = res6 . model . optimresults [ '<STR_LIT>' ] <EOL> print ( np . sqrt ( np . diag ( hopt ) ) ) </s>
