You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This function computes aggregation statistics for each distinct value of 'factor', e.g.panel unit
function void panel_agg_grouped (const list Targets,
const strings Metrics,
const series factor)
/* Print summary statistics for each metric in 'Metrics' for each
panel unit in 'factor'. Each table refers to some metric.
For a given metric a table (matrix) will be
printed. Rows refer to the factor units and columns to the statistics of
each target series. */
strings factor_names = strvals(factor) # TODO: check for existence
strings column_labels = varnames(Targets)
loop foreach i Metrics
result = aggregate(Targets, factor, "$i")[,3:] # disregard "id" and "nobs" columns
rnameset(result, factor_names) # TODO: only if present
cnameset(result, column_labels)
printf "\n*** Summary statistics for metric '%s' ***\n\n", "$i"
printf "%16.2f\n", result
endloop
end function
Example output is
*** Summary statistics for metric 'mean' ***
d_production d_building d_permits d_income d_houseprice d_interest d_unemployment
GER -0.04 -0.09 -0.36 0.09 0.02 -0.01 -0.00
FRA -0.01 0.00 -0.08 0.12 0.11 -0.01 -0.00
ITA 0.13 nan -0.69 -0.01 -0.06 -0.00 -0.00
ESP -0.52 -0.19 -1.38 0.06 0.11 -0.01 -0.01
NED 0.08 0.12 0.10 0.03 0.24 -0.01 -0.01
BEG 0.01 -0.01 0.03 0.02 0.15 -0.01 -0.00
AUT 0.16 0.19 -0.01 0.01 0.15 -0.00 0.00
POR -0.78 -0.74 -1.25 0.01 nan -0.01 0.00
GRE nan nan 0.41 0.00 0.20 -0.02 -0.00
IRE nan nan -0.37 0.02 0.23 0.00 -0.02
Todo
Think about a better function name
But return each matrix as a bundle item
Add a print function for convenience only
Add a parameter bundle, e.g. for setting the number of digits or so
The text was updated successfully, but these errors were encountered:
What it does?
Example output is
Todo
The text was updated successfully, but these errors were encountered: