Analysis of many companies over a period

I'm trying to see the relationship between some variables, for example, with the model below

$$\text{Profitability} = \varepsilon + \beta_0 + \beta_1 \text{DoL} + \beta_2 \text{DFL} + \beta_3 \text{SZ}$$

with:
DoL = Degree of Operating Leverage
DFL = Degree of Financial Leverage
SZ = Firm size

and those data are taken from financial statements However, I don't know how to perform the regression analysis because I have data of many companies, and for each companies, I have data for 10 years. So i'm not sure should I use the average of all companies (this will become the sector) for each year, or should I run the regression with average of each company over the period.

Averaging over companies is a bad idea and could lead you to biased results because it would lead you to use group-level (averaged results) and individual-level results as the same while they are different entities (see an example in here).

The valid approach would be to use a multilevel model where where time is nested in companies. So simplifying it is:

$$y_{ij} = \beta_0 + \beta_1 X_{1ij} + ... + \beta_k X_{kij} + b_i + \varepsilon_{ij}$$

where $\beta$ are fixed effects, $b_i$ is random intercept for each of the $i$'th companies and $j$ is an index of time. Different models are also possible, for example with random slopes.

This kind of models are implemented in multiple software, including the great lme4 package for R.

You can read more for example in:

• Snijders, T.A.B. & Bosker, R.J. (2012). Multilevel Analysis: An Introduction to Basic and Advanced Multilevel Modeling. London: Sage Publishers.
• Hox, J. (2010). Multilevel Analysis: Techniques and Applications. New York: Routledge.
• Gelman, A. & Hill, J. (2006). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press.