Dear Statalist members,

I am new to Stata and this is my first post.

I want to estimate a translog cost function and its partial derivative (marginal cost). I need the estimate of marginal cost for every year for every bank to estimate my Lerner Index. I use panel data for over 2000 banks over 8 periods (ranging from 2011 to 2018).
I am not sure how to estimate the things described above, cause Stata ends the regression of my translog cost function due to "insufficient observations". Thats possibly because I try to estimate a single line of my data - One bank at a specific year. I do not know how to proceed... But I need the marginal costs for each bank in each year. For any advice I will be more than glad. I've read a paper, where they use OLS, so I want to do the same.

Here is a very short overview of my data

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte id_bank int year double(tc q1) float(q2 w1 w2 w3)
1 2011     55000   2910016  3064633  .019  .017 .00099
1 2012     48000   3291208  3417275  .014  .018  .0012
1 2013     96000   4693980  4880171  .013  .016  .0014
1 2014     91000   3866875  3808000 .0098  .022  .0017
1 2015    266800   7114940  8787466 .0067  .019  .0078
1 2016    242500   6990195  8525062  .004  .016  .0058
1 2017    290000   7905072 10314923 .0036  .019   .003
1 2018    286000 8562460.9 10845030 .0037  .017  .0025
2 2011         .         .        .     .     .      .
2 2012         .         .        .     .     .      .
2 2013 261510.46  12342217 13048772  .014  .013  .0021
2 2014    202784  10891645 11083400  .011  .014 .00077
2 2015  207959.1   9841932  9840160 .0066  .015  .0011
2 2016    201420   9770153  9562544 .0048  .014  .0013
2 2017    246413  11439694 10876763 .0037  .017   .002
2 2018    243999  11253174 11242116 .0068  .018  .0012
3 2011    119539   8882993  7307546   .04  .009 .00043
3 2012    126488   9735650  8199895  .028 .0087 .00046
3 2013    143777  10110711  8207365  .029  .009 .00044
3 2014    143369   8192736  7233554  .027  .013 .00025
3 2015    125294   7752964  6986139   .02   .01  .0006
3 2016    116501   8372932  7324262  .019 .0092 .00054
3 2017    133004   9060156  8461524  .017 .0095 .00048
3 2018    141117   9152467  8232791 .0057 .0097 .00074
end

Code:
tsset id_bank year, yearly
The next two commands I have found in the mentioned Article (https://www.statalist.org/forums/for...ata-estimation)

Code:
*\\ TAKING THE LOGS OF VARIABLES 
foreach var in tc q1 q2 w1 w2 w3 {
gen double ln_`var'= ln(`var')
}
Code:
*\\ MULTIPLY SQUARED TERMS BY 0.5
foreach var in q1 q2 w1 w2 w3  {
gen double ln_`var'2 =  0.5*(ln_`var')^2
}

Code:
forvalues y = 2011(1) 2018 {
forvalues i = 1(1) 3 {
    display `y'
    display `i'
    capture reg ln_tc ln_q1 ln_q2 ln_q12 ln_q22 c.ln_q1#c.ln_q2 ln_w1 ln_w2 ln_w3 ln_w12 c.ln_w1#c.ln_w2 c.ln_w1#c.ln_w3 ln_w22 c.ln_w2#c.ln_w3 ln_w32 c.ln_q2#c.ln_w1 c.ln_q2#c.ln_w2 c.ln_q2#c.ln_w3 c.ln_q1#c.ln_w1 c.ln_q1#c.ln_w2 c.ln_q1#c.ln_w3 if `y' == year& `i'== id_bank
}
}
I know that this is not complete, but if my regression does not work, I could not proceed with the derivative (margins or lncom?). And I have to store the marginal cost for each bank in each year...

Thanks for any help.