<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> from statsmodels . compat . python import zip <EOL> from datetime import datetime <EOL> import numpy as np <EOL> from pandas import DataFrame , Series , datetools <EOL> import statsmodels . api as sm <EOL> import statsmodels . tsa . api as tsa <EOL> data = sm . datasets . stackloss . load ( ) <EOL> X = DataFrame ( data . exog , columns = data . exog_name ) <EOL> X [ '<STR_LIT>' ] = <NUM_LIT:1.> <EOL> Y = Series ( data . endog ) <EOL> model = sm . OLS ( Y , X ) <EOL> results = model . fit ( ) <EOL> print ( results . summary ( ) ) <EOL> print ( results . params ) <EOL> print ( results . cov_params ( ) ) <EOL> infl = results . get_influence ( ) <EOL> print ( infl . summary_table ( ) ) <EOL> huber_t = sm . RLM ( Y , X , M = sm . robust . norms . HuberT ( ) ) <EOL> hub_results = huber_t . fit ( ) <EOL> print ( hub_results . params ) <EOL> print ( hub_results . bcov_scaled ) <EOL> print ( hub_results . summary ( ) ) <EOL> import matplotlib . pyplot as plt <EOL> from matplotlib import cm <EOL> import matplotlib as mpl <EOL> def plot_acf_multiple ( ys , lags = <NUM_LIT:20> ) : <EOL> """<STR_LIT:U+0020>""" <EOL> from statsmodels . tsa . stattools import acf <EOL> old_size = mpl . rcParams [ '<STR_LIT>' ] <EOL> mpl . rcParams [ '<STR_LIT>' ] = <NUM_LIT:8> <EOL> plt . figure ( figsize = ( <NUM_LIT:10> , <NUM_LIT:10> ) ) <EOL> xs = np . arange ( lags + <NUM_LIT:1> ) <EOL> acorr = np . apply_along_axis ( lambda x : acf ( x , nlags = lags ) , <NUM_LIT:0> , ys ) <EOL> k = acorr . shape [ <NUM_LIT:1> ] <EOL> for i in range ( k ) : <EOL> ax = plt . subplot ( k , <NUM_LIT:1> , i + <NUM_LIT:1> ) <EOL> ax . vlines ( xs , [ <NUM_LIT:0> ] , acorr [ : , i ] ) <EOL> ax . axhline ( <NUM_LIT:0> , color = '<STR_LIT:k>' ) <EOL> ax . set_ylim ( [ - <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> ax . set_xlim ( [ - <NUM_LIT:1> , xs [ - <NUM_LIT:1> ] + <NUM_LIT:1> ] ) <EOL> mpl . rcParams [ '<STR_LIT>' ] = old_size <EOL> data = sm . datasets . macrodata . load ( ) <EOL> mdata = data . data <EOL> df = DataFrame . from_records ( mdata ) <EOL> quarter_end = datetools . BQuarterEnd ( ) <EOL> df . index = [ quarter_end . rollforward ( datetime ( int ( y ) , int ( q ) * <NUM_LIT:3> , <NUM_LIT:1> ) ) <EOL> for y , q in zip ( df . pop ( '<STR_LIT>' ) , df . pop ( '<STR_LIT>' ) ) ] <EOL> logged = np . log ( df . ix [ : , [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ] ) <EOL> logged . plot ( subplots = True ) <EOL> log_difference = logged . diff ( ) . dropna ( ) <EOL> plot_acf_multiple ( log_difference . values ) <EOL> model = tsa . VAR ( log_difference , freq = '<STR_LIT:D>' ) <EOL> print ( model . select_order ( ) ) <EOL> res = model . fit ( <NUM_LIT:2> ) <EOL> print ( res . summary ( ) ) <EOL> print ( res . is_stable ( ) ) <EOL> irf = res . irf ( <NUM_LIT:20> ) <EOL> irf . plot ( ) <EOL> fevd = res . fevd ( ) <EOL> fevd . plot ( ) <EOL> print ( res . test_causality ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> '''<STR_LIT>''' <EOL> import numpy as np <EOL> import statsmodels . api as sm <EOL> from statsmodels . tsa . arima_process import arma_generate_sample <EOL> arparams = np . array ( [ <NUM_LIT> , - <NUM_LIT> ] ) <EOL> maparams = np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> arparams = np . r_ [ <NUM_LIT:1> , - arparams ] <EOL> maparam = np . r_ [ <NUM_LIT:1> , maparams ] <EOL> nobs = <NUM_LIT> <EOL> y = arma_generate_sample ( arparams , maparams , nobs ) <EOL> plt . figure ( ) <EOL> plt . plot ( y ) <EOL> dates = sm . tsa . datetools . dates_from_range ( '<STR_LIT>' , length = nobs ) <EOL> y = Series ( y , index = dates ) <EOL> arma_mod = sm . tsa . ARMA ( y , freq = '<STR_LIT:M>' ) <EOL> plt . show ( ) </s>
