Skip to content

Commit

Permalink
Added an error message for panel data and a heterogeneity test
Browse files Browse the repository at this point in the history
Added data examination before the command is run and a sdtest
  • Loading branch information
econcz committed Apr 1, 2024
1 parent 0be8330 commit 3660b48
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
26 changes: 24 additions & 2 deletions xtarimau.ado
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*! version 1.0.2 07oct2022 I I Bolotov
*! version 1.0.3 07oct2022 I I Bolotov
program define xtarimau, rclass
version 16.0
/*
Expand Down Expand Up @@ -50,13 +50,17 @@ program define xtarimau, rclass
syntax ///
[varlist(ts fv)] [if] [in] [iw] [, ///
PREestimation(string asis) POSTestimation(string asis) ///
export(string asis) * ///
export(string asis) SDtest * ///
]
// adjust and preprocess options
loc `tmp' = ustrregexm(`"`options'"', ".*ic\((\w+)\).*", 1)
loc ic = cond(ustrregexs(1) == "", "aic", ustrregexs(1))
// get timevar, panelvar and panelval
qui tsset, noq
if "`r(panelvar)'" == "" { // examine data
di as err "command requires panel data"
exit 459
}
loc `timevar' = r(timevar)
loc `panelvar' = r(panelvar)
qui levelsof ``panelvar'', matrow(`panelval')
Expand Down Expand Up @@ -158,6 +162,24 @@ program define xtarimau, rclass
"%5.0f & %5.0f & %6.0f | %12.4f &"
matlist `models', title(``title'') rspec(``rspec'') cspec(``cspec'')
}
// print tests
if trim(`"`sdtest'"') != "" {
mata: p = (! strpos(st_local("options"), "stat") ? 1..3 : (1,3)), /*
*/ (! strpos(st_local("options"), "seas") ? 4..6 : J(1,0,.))
mata: for(i = 1; i <= cols(p); i++) {; ///
printf("\n{res}" + ("p","d","q","P","D","Q")[p[i]] + ///
" {txt}in {res}" + (p[i] <= 3 ? "arima(#p,#d,#q)" ///
: "sarima(#P,#D,#Q)") ///
); ///
(void) _stata("sdtesti " + ///
strofreal(rows(st_matrix("`models'"))) + ///
" . " + ///
strofreal(sqrt(variance( ///
st_matrix("`models'")[.,p[i]] ///
))) + " 0" ///
); };
mata: mata drop p i
}
// return output
cap ret loc ictests ``ictests''
cap ret loc icarima ``icarima''
Expand Down
12 changes: 11 additions & 1 deletion xtarimau.sthlp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{smcl}
{* *! version 1.0.2 07oct2022}{...}
{* *! version 1.0.3 07oct2022}{...}
{vieweralsosee "[TS] arima" "mansection TS arima"}{...}
{vieweralsosee "" "--"}{...}
{vieweralsosee "[TS] arima postestimation" "help arima postestimation"}{...}
Expand Down Expand Up @@ -68,6 +68,8 @@ panels with the help of {helpb arimaauto}
be ignored{p_end}
{synopt:{helpb kpss##options:kpss(...)}}options directly passed to {helpb kpss}
except {opth maxl:ag(#)} which will be ignored{p_end}
{synopt:{opt sd:test}}a test for heterogeneity, i.e., whether the standard
deviations of #p, #d, #q, #P, #D, #Q across the panel are {bf:0}{p_end}

{syntab:ARIMA-related}
{synopt:{opt nocons:tant}}suppress constant term if both
Expand Down Expand Up @@ -200,6 +202,14 @@ examples.
help of the Schwert (1989) formula(s) (the default) or {cmd:xtarimau}'s
{opth maxl:ag(#)} option.

{pstd}
{ul:Heterogeneity tests:}

{pstd}
A set of {helpb sdtesti} commands, called via the {bf:{opt sd:test}} option,
is used to test whether the standard deviations of #p, #d, #q, #P, #D, #Q in
{bf:r(models)} are equal to 0.

{marker options}{...}
{title:Options}

Expand Down

0 comments on commit 3660b48

Please sign in to comment.