6  For Stata users

In this example, the package functions are combined in such a way that the results obtained are more or less familiar to those users who are accustomed to using Stata.

6.1 Set up

Import the package.

library(paneldesc)

6.2 Data import

Import the built-in dataset with simulated unbalanced panel data.

data(production)

6.3 summarize

You can look at the simple descriptive statistics with summarize_numeric().

summarize_numeric(production)
Analyzing all numeric variables: firm, year, sales, capital, labor
variable count mean std min max
firm 180 15.500 8.680 1.000 30.000
year 180 3.500 1.713 1.000 6.000
sales 154 69.756 46.804 8.321 336.853
capital 154 32.490 31.053 0.968 194.719
labor 154 79.329 73.687 4.097 419.848

6.4 xtset

You can set up a panel structure in advance so that you don’t have to do it later each time you use other functions. Note that if delta is supplied, the function checks for omitted time periods. If such periods exist, they will be taken into account when other functions work with this argument.

panel <- make_panel(production, index = c("firm", "year"), delta = 1)

6.5 xtdes

xtdes command funcitonality can be reproduced by combining describe_dimensions(), describe_balance(), and describe_patterns() functions.

describe_dimensions(panel)
rows entities periods variables
180 30 6 5
describe_balance(panel, detail = TRUE)
dimension mean std min p5 p25 p50 p75 p95 max
entities 26.167 3.971 19 20.5 25.25 27 28.75 29.75 30
periods 5.233 0.935 3 4.0 4.25 6 6.00 6.00 6
describe_patterns(panel)
pattern 1 2 3 4 5 6 count share
1 1 1 1 1 1 1 16 0.533
2 1 1 1 1 1 0 5 0.167
3 1 1 1 1 0 0 3 0.100
4 0 0 1 1 1 1 2 0.067
5 0 1 1 1 1 0 2 0.067
6 0 1 1 1 1 1 1 0.033
7 1 1 1 0 0 0 1 0.033

6.6 xtsum

xtsum command funcitonality can be reproduced with decompose_numeric() function.

decompose_numeric(panel)
Analyzing all numeric variables: sales, capital, labor
variable dimension mean std min max count
sales overall 69.756 46.804 8.321 336.853 154.000
sales between NA 29.776 25.772 159.197 30.000
sales within NA 35.862 -28.397 247.412 5.133
capital overall 32.490 31.053 0.968 194.719 154.000
capital between NA 13.969 8.671 75.083 30.000
capital within NA 27.701 -22.444 152.126 5.133
labor overall 79.329 73.687 4.097 419.848 154.000
labor between NA 44.023 24.606 175.731 30.000
labor within NA 59.561 -77.709 323.445 5.133

6.7 xttab

xttab command funcitonality can be reproduced with decompose_factor() function.

decompose_factor(panel)
Analyzing all factor variables: industry, ownership
variable category count_overall share_overall count_between share_between share_within
industry Industry 1 63 0.401 13 0.433 0.918
industry Industry 2 45 0.287 11 0.367 0.809
industry Industry 3 49 0.312 10 0.333 0.917
ownership private 76 0.484 16 0.533 0.898
ownership public 55 0.350 13 0.433 0.813
ownership mixed 26 0.166 7 0.233 0.724

6.8 xttrans

xttrans command funcitonality can be reproduced with summarize_transition() function.

summarize_transition(panel, select = "industry")
23 rows with NA values in 'industry' removed.
from_to Industry 1 Industry 2 Industry 3
Industry 1 1.000 0.000 0.000
Industry 2 0.054 0.919 0.027
Industry 3 0.000 0.025 0.975