statistics - How to fit a restricted VAR model in Python (statsmodels)? -


the question interested in restricting non significant parameters in var model var(2). how may in python 3.0x?

the question raised r not python

how fit restricted var model in r?

can please me figure out?

to knowledge, not able find python package able kind of restriction. however, there package in r known vars. therefore, had augment r package in python using rpy2 interface.

this may done there list of events should take place allows python call r functions (even packages) vars package.

a summary using different package may found in link

however, sake of illustration here code

first have import vars python as

# import vars rvars = importr("vars", lib_loc = "c:/users/rami chehab/documents/r/win-library/3.3") 

then 1 need fit var model data (or dataframe) data as

t=rvars.var(data,p=2, type='const') 

then afterwards 1 needs apply different function in vars packages known restrict removes nonsignificant parameters

# let try restricting t1=rvars.restrict(t,method = "ser") 

the final steps allow observe data call built-in function in r known summary as

# calling built-in functions r rsummary = robjects.r['summary'] 

now print outcome as

print(rsummary(t1)) 

this give

estimation results equation ireland.real.bond:   ==================================================   ireland.real.bond = ireland.real.bond.l1 + ireland.real.equity.l1 + ireland.real.bond.l2                            estimate std. error t value pr(>|t|)     ireland.real.bond.l1    0.26926    0.11139   2.417  0.01739 *   ireland.real.equity.l1 -0.21706    0.07618  -2.849  0.00529 **  ireland.real.bond.l2    0.23929    0.09979   2.398  0.01829 *   ---  signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1      residual standard error: 14.41 on 103 degrees of freedom  multiple r-squared: 0.1041, adjusted r-squared: 0.07799   f-statistic: 3.989 on 3 , 103 df,  p-value: 0.009862       estimation results equation ireland.real.equity:   ====================================================   ireland.real.equity = ireland.real.bond.l1 + ireland.real.equity.l1 + const                            estimate std. error t value pr(>|t|)      ireland.real.bond.l1     0.7253     0.1585   4.575 1.33e-05 ***  ireland.real.equity.l1  -0.3112     0.1068  -2.914 0.004380 **   const                    7.7494     2.1057   3.680 0.000373 ***  ---  signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1      residual standard error: 20.58 on 103 degrees of freedom  multiple r-squared: 0.2462, adjusted r-squared: 0.2243   f-statistic: 11.21 on 3 , 103 df,  p-value: 1.984e-06  

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -