<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import numpy as np <EOL> from numpy . testing import assert_almost_equal <EOL> import statsmodels . api as sm <EOL> np . random . seed ( <NUM_LIT> ) <EOL> nobs = <NUM_LIT:10> <EOL> x1 = np . random . randn ( nobs ) <EOL> y1 = <NUM_LIT:10> + <NUM_LIT:15> * x1 + <NUM_LIT:2> * np . random . randn ( nobs ) <EOL> x1 = sm . add_constant ( x1 , prepend = False ) <EOL> assert_almost_equal ( x1 , np . vander ( x1 [ : , <NUM_LIT:0> ] , <NUM_LIT:2> ) , <NUM_LIT:16> ) <EOL> res1 = sm . OLS ( y1 , x1 ) . fit ( ) <EOL> print ( res1 . params ) <EOL> print ( np . polyfit ( x1 [ : , <NUM_LIT:0> ] , y1 , <NUM_LIT:1> ) ) <EOL> assert_almost_equal ( res1 . params , np . polyfit ( x1 [ : , <NUM_LIT:0> ] , y1 , <NUM_LIT:1> ) , <NUM_LIT> ) <EOL> print ( res1 . summary ( xname = [ '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> x2 = np . random . randn ( nobs ) <EOL> y2 = <NUM_LIT> + <NUM_LIT> * x2 + <NUM_LIT:2> * np . random . randn ( nobs ) <EOL> x2 = sm . add_constant ( x2 , prepend = False ) <EOL> assert_almost_equal ( x2 , np . vander ( x2 [ : , <NUM_LIT:0> ] , <NUM_LIT:2> ) , <NUM_LIT:16> ) <EOL> res2 = sm . OLS ( y2 , x2 ) . fit ( ) <EOL> print ( res2 . params ) <EOL> print ( np . polyfit ( x2 [ : , <NUM_LIT:0> ] , y2 , <NUM_LIT:1> ) ) <EOL> assert_almost_equal ( res2 . params , np . polyfit ( x2 [ : , <NUM_LIT:0> ] , y2 , <NUM_LIT:1> ) , <NUM_LIT> ) <EOL> print ( res2 . summary ( xname = [ '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> x = np . concatenate ( ( x1 , x2 ) , <NUM_LIT:0> ) <EOL> y = np . concatenate ( ( y1 , y2 ) ) <EOL> dummy = np . arange ( <NUM_LIT:2> * nobs ) > nobs - <NUM_LIT:1> <EOL> x = np . column_stack ( ( x , x * dummy [ : , None ] ) ) <EOL> res = sm . OLS ( y , x ) . fit ( ) <EOL> print ( res . summary ( xname = [ '<STR_LIT:x>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( res . f_test ( [ [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> ] , [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ] ] ) ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( res1 . params , res2 . params ) <EOL> print ( res . params [ : <NUM_LIT:2> ] , res . params [ : <NUM_LIT:2> ] + res . params [ <NUM_LIT:2> : ] ) <EOL> assert_almost_equal ( res1 . params , res . params [ : <NUM_LIT:2> ] , <NUM_LIT> ) <EOL> assert_almost_equal ( res2 . params , res . params [ : <NUM_LIT:2> ] + res . params [ <NUM_LIT:2> : ] , <NUM_LIT> ) </s>
