Skip to content

Commit

Permalink
add a couple of unit tests relating to addobs
Browse files Browse the repository at this point in the history
  • Loading branch information
AllinCottrell committed Jan 24, 2025
1 parent c2eece7 commit a2a1259
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
31 changes: 31 additions & 0 deletions unittests/test_scripts/commands/run_panel_add_time.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
set verbose off
clear
set assert stop

# artificial "outer" panel data
nulldata 6
setobs 2 1:1 --stacked-time-series
genr time
series country = $unit
series year = time + 2001
series x = year * country
delete index time
store rhs.csv

# artificial "inner" panel data
nulldata 6
setobs 2 1:1 --stacked-time-series
genr time
series country = $unit
series year = time + 1999
series x = year * country
delete index time

# extend LHS in time dimension
dataset addobs 2 --panel-time
# stick in the RHS data
join rhs.csv x --ikey=country,year
remove("rhs.csv")

assert({x} == {year * country})
print -o
31 changes: 31 additions & 0 deletions unittests/test_scripts/commands/run_panel_add_units.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
set verbose off
clear
set assert stop
set seed 12345

nulldata 6
setobs 2 1:1 --stacked-time-series
genr time
series country = $unit + 3
series year = time + 1999
series x = year * country
delete index time
store rhs.csv

# artificial panel data
nulldata 6
setobs 2 1:1 --stacked-time-series
genr time
series country = $unit
series year = time + 1999
series x = year * country
delete index time

# extend LHS in cross-sectional dimension
dataset addobs 3
# add the RHS data
join rhs.csv x --ikey=country,year
remove("rhs.csv")

assert({x} == {year * country})
# print -o

0 comments on commit a2a1259

Please sign in to comment.