Quantcast
Channel: Statalist
Viewing all 72862 articles
Browse latest View live

non-linear optimisation with linear restrictions

$
0
0
Dear all: I need to find the B vector that minimises the following non-linear function (B-A)*IM*(B-A) such that a linear restriction (also involving the vector B) is fulfilled. It is not necessary to write the restriction in this post. A is the vector of coefficients from my non-restricted model and IM is the inverse of the var/cov matrix from my non-restricted model.
Is it possible to do this in Mata? I use Stata 15. I haven't found any tutorial nor examples of this. I would appreciate your advice ... Many thanks, Juan

Data which contain Multiple followups with hours variables

$
0
0
Dear Statlist Users,

Hope all you experts are doing great.I wanted to understand how to analyze the data which contains multiple followups, for example data contain 47 followups depend on different days. and each followup contain baby breast feeding practices in 24 hours. Data has been taken hourly ( How many times baby has been fed in per hour ).
if any can one reply please?

Problem with Reshape on Panel Data

$
0
0
Hi all,
My aim is to make variable id to be unique and I think reshape is the command instead of collapse.
When I was tried with reshape from long to wide, error appear in output:
Some error are:

code : reshape wide hi06 hi07, i(id) j(hi01) string
output: r(109); variable hi01 is numeric

I did convert data hi01 to string
command: tostring hi01, replace
hi01 was byte now str1

and did command : . reshape wide hi06 hi07, i(id) j(hi01) string
output :
(note: j = 1 3 8)
values of variable hi01 not unique within id
Your data are currently long. You are performing a reshape wide. You
specified i(id) and j(hi01). There are observations within i(id) with the
same value of j(hi01). In the long data, variables i() and j() together
must uniquely identify the observations.

long wide
+---------------+ +------------------+
| i j a b | | i a1 a2 b1 b2 |
|---------------| <--- reshape ---> |------------------|
| 1 1 1 2 | | 1 1 3 2 4 |
| 1 2 3 4 | | 2 5 7 6 8 |
| 2 1 5 6 | +------------------+
| 2 2 7 8 |
+---------------+
Type reshape error for a list of the problem variables.
r(9);

I also did several combination to reshape, including dropping some variables that not really urgent for my analysis (especially drop variable with missing value), therefore the variables left are: id, hi01, hi06, but result almost the same either. Probably I do not really understand the reshape structure.
Thanks in advance.

[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input str1(hi01 hitype) byte(hi02 hi06 hi07 hi08x) str9 id
"3" "." . 3 . . "001220001"
"3" "." . 3 . . "001220002"
"3" "." . 3 . . "001220003"
"3" "." . 3 . . "001220004"
"3" "." . 3 . . "001220005"
"3" "." . 3 . . "001220011"
"3" "." . 3 . . "001250001"
"3" "." . 3 . . "001250002"
"3" "." . 3 . . "001250003"
"3" "." . 3 . . "001290001"
"3" "." . 3 . . "001290002"
"3" "." . 3 . . "001290003"
"3" "." . 3 . . "002010001"
"3" "." . 3 . . "002010002"
"3" "." . 3 . . "002010003"
"3" "." . 3 . . "002010004"
"3" "." . 3 . . "002020003"
"3" "." . 3 . . "002020007"
"3" "." . 3 . . "002030001"
"3" "." . 3 . . "002030002"
"3" "." . 3 . . "002040001"
"3" "." . 3 . . "002040002"
"3" "." . 3 . . "002090001"
"3" "." . 3 . . "002090002"
"1" "A" 3 3 . . "002090003"
"1" "D" 3 3 . . "002090003"
"1" "C" 3 3 . . "002090003"
"1" "B" 1 3 . . "002090003"
"1" "V" 3 3 . . "002090003"
"1" "C" 3 3 . . "002090006"
"1" "D" 3 3 . . "002090006"
"1" "A" 3 3 . . "002090006"
"1" "B" 1 3 . . "002090006"
"1" "V" 3 3 . . "002090006"
"3" "." . 3 . . "002090007"
"1" "D" 3 3 . . "002093102"
"1" "V" 3 3 . . "002093102"
"1" "A" 3 3 . . "002093102"
"1" "C" 3 3 . . "002093102"
"1" "B" 1 3 . . "002093102"
"3" "." . 3 . . "002093202"
"1" "D" 3 3 . . "002093301"
"1" "V" 3 3 . . "002093301"
"1" "A" 3 3 . . "002093301"
"1" "C" 3 3 . . "002093301"
"1" "B" 1 3 . . "002093301"
"3" "." . 3 . . "002100001"
"3" "." . 3 . . "002100002"
"3" "." . 3 . . "002110001"
"3" "." . 3 . . "002110002"
"3" "." . 3 . . "002120001"
"3" "." . 3 . . "002140001"
"3" "." . 3 . . "002140002"
"3" "." . 3 . . "002160001"
"3" "." . 3 . . "002180003"
"3" "." . 3 . . "002180004"
"3" "." . 3 . . "002180005"
"3" "." . 3 . . "002183101"
"3" "." . 3 . . "002190001"
"1" "B" 3 3 . . "002200001"
"1" "A" 1 3 . . "002200001"
"1" "V" 3 3 . . "002200001"
"1" "C" 3 3 . . "002200001"
"1" "D" 3 3 . . "002200001"
"3" "." . 3 . . "002210001"
"3" "." . 3 . . "002250001"
"3" "." . 3 . . "002250002"
"3" "." . 3 . . "002250007"
"3" "." . 3 . . "002260001"
"3" "." . 3 . . "002260002"
"3" "." . 3 . . "002260005"
"3" "." . 3 . . "002260006"
"3" "." . 3 . . "002270001"
"3" "." . 3 . . "002270002"
"3" "." . 3 . . "002270003"
"3" "." . 3 . . "002270004"
"3" "." . 3 . . "002270006"
"3" "." . 3 . . "002290001"
"3" "." . 3 . . "002290002"
"3" "." . 3 . . "002290006"
"3" "." . 3 . . "002300001"
"3" "." . 3 . . "002300006"
"3" "." . 3 . . "002300011"
"3" "." . 3 . . "003010001"
"3" "." . 3 . . "003010002"
"3" "." . 3 . . "003010005"
"3" "." . 3 . . "003020002"
"3" "." . 3 . . "003020003"
"3" "." . 3 . . "003030001"
"3" "." . 3 . . "003030004"
"3" "." . 3 . . "003030005"
"3" "." . 3 . . "003031201"
"3" "." . 3 . . "003040002"
"3" "." . 3 . . "003050001"
"3" "." . 3 . . "003050002"
"3" "." . 3 . . "003050004"
"3" "." . 3 . . "003050006"
"3" "." . 3 . . "003070002"
"3" "." . 3 . . "003070005"
"3" "." . 3 . . "003080001"

help with local macros

$
0
0
Dear all,
I would like to create several boxplots at once and combine them. i found the code below and it works very well. can some one help me understand the different sections. i understand the foreach command but i am confused about the rest mainly
local names `names' graph`j'
local j

Thanks in advance


Code:
local j = 1
local names
foreach var of varlist A-X {
     graph box  `var', name(graph`j')
     local names `names' graph`j'
     local j
}

graph combine `names'
Stata 15.1 Mac

Number of rows and columns of subplots using xtline

$
0
0
Hi,

how can I define the number of rows/columns of subplots when using "xtline"? The options "rows()" and "cols()" do not work:

input: "xtline var1, rows(2)"
output: "option rows() not allowed"

Same with "cols(#)". Any ideas?

Thanks

Ramsey test

$
0
0
Hi,

Which is the command in Stata 12 for the Ramsey Test with data panel?

Thanks!

only the estimated coefficient

$
0
0
Hi,

Which could be the reason that Stata shows me only the estimated coefficient?:


------------------------------------------------------------------------------
| Robust
ln_TRADE | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------

ln_DIST | -.7334557 . . . . .
CNTG | 1.421494 . . . . .
LANG | -3.674322 . . . . .
CLNY | 6.189377 . . . . .
_cons | 17.52462 . . . . .
--------------------------------------------------------------------------------------


Thanks!

Stata : Rr mantel heanzel

$
0
0
I have SMR results by lauching this command : strate maxexpo_ardbis, per(100000) smr(taux_esto)
and i want to have the RR of mantel Haenzel, rr which measures the tendency of increase or decrease of the SMRs according to the classes of the variable maxexpo_ardbis.
Do you know which command i have to lauch for that ?
Thank you so much for your return,
Kind regards,

Variance of each single residual

$
0
0
Hi Statlist,

I am struggling into constructing the residuals' specific variance for the following model:

Code:
xtreg tasso_crescita_sales_prod L.log_sales L.dummy_2 L2.dummy_2 L3.dummy_2 mean_gr_rate_atc2 recalls_sales ageprodcat1 ageprodcat2 ageprodcat3 ageprodcat4 newmolfirm newmolmarket i.Year, fe vce(cluster idpr)
What I would like to do is to generate a variable consisting of the variance of regression residuals so that each residual has its own variance (not gen var = e(sigma_e) which generates a unique value). So, if we call the residuals AVit (resulting from AVit = y - yhat where yhat = predict yhat, xbu) , I would like to obtain Var(AVit ). Afterwords my aim is to compute the average over Nt , where Nt is the number of units with available data in t of such variances. Something like:

Sum for i ranging from 1 to Nt of Var(AVit ) over (Nt )2​​​​​​​


Is it possible in STATA to do compute the variance of such residuals?

Unobserved Componenet Model and State Space Model

$
0
0
Dear All

I am try trying to construct an index, using Unobserved Component Model (UCM) and State Space Model (SSM) in Stata, but I am really struggling with the right syntax/command.
I have already used Principal Component Analysis (PCA) but a lot of observations were dropped in the process.
With UCM and SSM; I have read a number of articles/journals on them but I do not have a good grasp of the commands. I got different kinds of error when I follow/use the ‘Statistics>Time-Series>UCM or Statistics>Time-Series>SMM’ routes in Stata.

I understand UCM and SSM are primarily designed for forecasting purposes but they have also been used to construct indices.


The whole idea of what I am doing is to use 3 different methods/models to construct the same index and see how they perform when used for further analysis:

-I am keeping the index constructed with PCA.

-I want to use UCM to construct another index without using Kalman Filter to address missing observation:
After dropping an observation due to having too many missing observations, I have 5 variables left to construct the index.
3 of the 5 variables are fairly complete (they have insignificant missing observations) while 2 of them have significant missing observations.
Following kaufmann et al (2010) in the construction of World Governance Indicator: I want the UCM to construct the index with any combination of 3 (or more) variables from the 5 variables; the 3 variables must include at least 2 of the 3 variables that are fairly complete variables and at least 1 of the 2 variables with significant missing observations.

-For SSM; I intend to use Kalman Filter to address missing observations when constructing the index with the model.

I need assistance on the UCM and SSM commands I need to construct the index with Stata.


I will provide further information if needed.


Your assistance will be very much appreciated.

Thank you.

How to extract a country specific value for each country in a panel data set

$
0
0
I have a panel date set wich consists of 49 countries and want to extract fed funds rate for each country. The variable interestrate have interest rate of each country and want to extract the values of the US
interestrate for each country in the data set.

How to save graphs from loop in particular folder

$
0
0
How to save graphs from loop in a particular folder.


I have my out foder:

global MY_OUT "C:\Users\out"

and the loop as below:




foreach y of varlist reer cpi gdpgr {
local graphtitle : var lab `y'
twoway (line c tp,title("`graphtitle'") legend(off) lwidth(0.25 ) ///
lcolor(black) lpattern(solid))(line trq tp,lwidth(0.4) lcolor(black) ///
lpattern(solid))(line l tp,lwidth(0.25 ) ///
lcolor(black) lpattern(longdash)) (line u tp ,lwidth(0.25 ) lcolor(black) ///
lpattern(longdash) ///
xlabel(-3 "t-3" -2 "t-2" -1 "t-1" 0 "t" 1 "t+1" 2 "t+2" 3 "t+3") ///
yline(0,lwidth(0.25 ) lcolor(black) lpattern(shortdash)) saving(`y' , replace ))
drop tp c trq l u
local graphnames `graphnames' `y'
}

I was using something like
saving($MY_OUT\`y' , replace ) but it still saves the graphs in my do folder and not in my out folder.








covariance structure in mixed model

$
0
0
Dear all,

I've been having problems selecting the correct covariance structure and for my mixed model (employees nested within firms).
When adding a (categorical) random slope (regarding the size of the firm) to my model, my model doesn't converge (backed up) with the default (independent) covariance structure and only converges when using the cov(exchangeable) option (for the R. notation, only independent and exchangeable covariance structures are available)
Code:
mixed jobsat level1fixedeffects level2fixedeffects || firmid: R.size
Did I understand it correctly, that one uses the exchangeable covariance structure only for repeated measures/panel/longitudinal data? I'm using pooled cross-sectional data, looking at firms for 2 consecutive years and treating the year variable as a fixed effect, so the observations (employees) on the first level are not the same for both years. I believe the covariance structure should therefore be independent and not exchangeable, so the non-convergence just tells me that the model is not sufficient and I shouldn't use it.

Please tell me if you need further information in order to answer my question regarding the covariance structure.
Your input will be greatly appreciated.

Felicia

Not concave issue with multinomiallogit regression

$
0
0
Dear Satalis,

I hope you are well. I would like to ask please regarding the problem of 'not concave' iteration. I have a dataset for 300 firms, one of the firms appears to be an outlier. When I excluded the outlier (i.e. to be only 299 firms) from the multinomial regression analysis (mlogit) the analysis iteration took a long time to perform the iteration and showed non-concavity in some iteration process. How to solve this problem please? Important to mention that when the outlier is not excluded the regression runs perfect but I got small value for the marginal effects results (for instance, 3.94E) for only one of the dependent variable estimation.



mlogit App_status i.I_sec i.AF_LEG i.AF_AGE i.AF_SIZE i.I_loct2 i.I_expt2 i.AF_GRWT i.BO_GEN i.BO_CIT i.BO_AGE i.ow_Exper2 i.BO_FINT i.BO_EDU i.CR_LEN i.CRBS1 i.CR_BS2 i.CR_BS3 i.CR_BS4 i.CR_BS5 i.CR_BS6 i.CR_BS7 i.CR_BS8 i.CR_SAT i.DE_ADS1 i.DE_ADS2 i.DE_ADS3 i.DE_ADS4 i.DE_ADS5 i.DE_ADS6 i.DE_ADS72 i.EI_BP i.EI_AUDFR

Iteration 0: log likelihood = -376.13767
Iteration 1: log likelihood = -240.52371
Iteration 2: log likelihood = -204.10375
Iteration 3: log likelihood = -190.49561
Iteration 4: log likelihood = -182.16412
Iteration 5: log likelihood = -174.29973
Iteration 6: log likelihood = -169.14731
Iteration 7: log likelihood = -167.60249
Iteration 8: log likelihood = -167.36518
Iteration 9: log likelihood = -167.30934
Iteration 10: log likelihood = -167.29729
Iteration 11: log likelihood = -167.29478
Iteration 12: log likelihood = -167.29422
Iteration 13: log likelihood = -167.29408
Iteration 14: log likelihood = -167.29405
Iteration 15: log likelihood = -167.29405 (not concave)
Iteration 16: log likelihood = -167.29405 (not concave)
Iteration 17: log likelihood = -167.29405 (not concave)
Iteration 18: log likelihood = -167.29405 (not concave)
Iteration 19: log likelihood = -167.29405 (not concave)
Iteration 20: log likelihood = -167.29405 (not concave)
Iteration 21: log likelihood = -167.29405 (not concave)
Iteration 22: log likelihood = -167.29405 (not concave)
Iteration 23: log likelihood = -167.29405 (not concave)
Iteration 24: log likelihood = -167.29405 (not concave)
Iteration 25: log likelihood = -167.29405 (not concave)
Iteration 26: log likelihood = -167.29405 (not concave)
Iteration 27: log likelihood = -167.29405 (not concave)
Iteration 28: log likelihood = -167.29405 (not concave)
Iteration 29: log likelihood = -167.29405 (not concave)
Iteration 30: log likelihood = -167.29405 (not concave)
Iteration 31: log likelihood = -167.29405 (not concave)
Iteration 32: log likelihood = -167.29405 (not concave)
Iteration 33: log likelihood = -167.29405 (not concave)
Iteration 34: log likelihood = -167.29405 (not concave)
Iteration 35: log likelihood = -167.29405 (not concave)
Iteration 36: log likelihood = -167.29405 (not concave)
Iteration 37: log likelihood = -167.29405 (not concave)
Iteration 38: log likelihood = -167.29405 (not concave)
Iteration 39: log likelihood = -167.29405 (not concave)
Iteration 40: log likelihood = -167.29405 (not concave)
Iteration 41: log likelihood = -167.29405 (not concave)
Iteration 42: log likelihood = -167.29405 (not concave)
Iteration 43: log likelihood = -167.29405 (not concave)
Iteration 44: log likelihood = -167.29405 (not concave)
Iteration 45: log likelihood = -167.29405 (not concave)
Iteration 46: log likelihood = -167.29405 (not concave)
Iteration 47: log likelihood = -167.29405 (not concave)
Iteration 48: log likelihood = -167.29405 (not concave)
Iteration 49: log likelihood = -167.29405 (not concave)
Iteration 50: log likelihood = -167.29405 (not concave)
Iteration 51: log likelihood = -167.29405 (not concave)
Iteration 52: log likelihood = -167.29405 (not concave)
Iteration 53: log likelihood = -167.29405 (not concave)
Iteration 54: log likelihood = -167.29405 (not concave)
Iteration 55: log likelihood = -167.29405 (not concave)
Iteration 56: log likelihood = -167.29405 (not concave)
Iteration 57: log likelihood = -167.29405 (not concave)
Iteration 58: log likelihood = -167.29405 (not concave)

--Break--
r(1);




Could you please advise on how to solve the problem of the non-concavity with mlogit analysis?
In case if I got small value such as 3.94E for the marginal effect, can I interpret these results to explain the relationship between the dependent and independent variables or should I exclude them (i.e. results) from the discussion part as they not given sense? in other words, what I should do when I got results for the marginal effect with very small values? How I should deal with?


Appreciate your kind help and cooperation

Best regards,
Rabab

PPML for one country

$
0
0
Hi,

If I estimate a gravity model using PPML from a balanced data panel for a several number of countries, but I would like to focus only in one specific country AAA is it the following correct? :


egen exp_time = group(exporter year)
quietly tabulate exp_time, gen(EXPORTER_TIME_FE)

egen imp_time = group(importer year)
quietly tabulate imp_time, gen(IMPORTER_TIME_FE)


ppml TRADE EXPORTER_TIME_FE* IMPORTER_TIME_FE* ln_DIST CNTG LANG CLNY RTA if exporter == "AAA" | importer == "AAA", cluster(DIST)




Or should I drop exporters and importers that are different from country AAA?

Thanks!

General xtabond2 queries

$
0
0
Dear Statalist,

I am examining quarterly data for an unbalanced panel of 11,000+ banks from 1996:Q1 to 2016:Q4 using Stata/IC. I am using a system gmm model through xtabond2. My regression code is as follows:

Code:
xtset id dateq

xtabond2 LCCF l.LCCF T1RAT SIZE RISK ROE MS MNA COMP POP INCG GDPG UNEM FFR q2_1997- q4_2016, ///
gmm(l.LCCF T1RAT SIZE RISK ROE MS MNA, lag(3 4) collapse) iv(COMP POP INCG GDPG UNEM FFR q2_1997- q4_2016) ///
twostep robust small nodiffsargan
For completeness, variables q2_1997- q4_2016 are dummies for each quarter to introduce time fixed effects. I have included all bank-level variables as endogenous in the -gmm- option, and all other variables as instruments in the -iv- option.

I understand that the -collapse- suboption of the -gmm- command is meant for datasets where the number of groups > number of instruments. This is obviously not the case with my data, as I have 11,000+ banks, so I do not think that it is necessary nor justified to include it. However, if I exclude the -collapse- suboption, using this code:

Code:
xtset id dateq

xtabond2 LCCF l.LCCF T1RAT SIZE RISK ROE MS MNA COMP POP INCG GDPG UNEM FFR q2_1997- q4_2016, ///
gmm(l.LCCF T1RAT SIZE RISK ROE MS MNA, lag(3 4)) iv(COMP POP INCG GDPG UNEM FFR q2_1997- q4_2016) ///
twostep robust small nodiffsargan
I get the following error:

Code:
                     J():  3900  unable to allocate real <tmp>[927864,588]
              _Explode():     -  function returned error
           _ParseInsts():     -  function returned error
         xtabond2_mata():     -  function returned error
                 <istmt>:     -  function returned error

Why does this error occur? xtabond2 seems very limited the detail of its error reporting.

Dyadic panel data: how to identify id overlaps between dyads over time? (common partners)

$
0
0
Dear Stata experts,

I have posted the question a couple of weeks back but didn't receive any feedback. I hope this is not a violation of the forum's rules if I re-post, witith a hopefully more meaningful title.

I am currently working on a project using panel data with 20.286 observations.

It is a dyadic panel in which a good (ship) has been chartered from an owner (identified with an "AOS owner" number) to a charterer (identified with an "AOS charterer" number). The panel is based on a dyadic identified (combining both AOS ids) and years from 2000-2017.

The dependent variable is a dummy "tie" capturing an existign transaction (deal) between the two (I filled in the panel forward based on existing deals).

The most important independent variable pertains to geography and is a dummy taking the value of one if both :the charterer and owner share the same geographic location *variable "same continent"). This is how the panel data looks like:


clear
input float dyad str14(aoscharterer aosowner) float(samecont tie) int Year
1 "
4081249" "175805" 0 1 2016
1 "
4081249" "175805" 0 0 2010
1 "
4081249" "175805" 0 0 2012
1 "
4081249" "175805" 0 0 2019
1 "
4081249" "175805" 0 0 2015
1 "
4081249" "175805" 0 0 2013
1 "
4081249" "175805" 0 0 2014
1 "
4081249" "175805" 0 0 2008
1 "
4081249" "175805" 0 0 2001
1 "
4081249" "175805" 0 0 2006
1 "
4081249" "175805" 0 0 2011
1 "
4081249" "175805" 0 0 2003
1 "
4081249" "175805" 0 0 2005
1 "
4081249" "175805" 0 0 2017
1 "
4081249" "175805" 0 0 2002
1 "
4081249" "175805" 0 0 2000
1 "
4081249" "175805" 0 0 2009
1 "
4081249" "175805" 0 0 2004
1 "
4081249" "175805" 0 0 2018
1 "
4081249" "175805" 0 0 2007
1 "
4081249" "175805" 0 0 1999
2 "
4081249" "5073238" 0 1 2017
2 "
4081249" "5073238" 0 0 2009
2 "
4081249" "5073238" 0 0 2007
2 "
4081249" "5073238" 0 0 2008
2 "
4081249" "5073238" 0 0 2012
2 "
4081249" "5073238" 0 0 2011
2 "
4081249" "5073238" 0 0 2016
2 "
4081249" "5073238" 0 0 1999
2 "
4081249" "5073238" 0 0 2000
2 "
4081249" "5073238" 0 0 2005
2 "
4081249" "5073238" 0 0 2004
2 "
4081249" "5073238" 0 0 2003
2 "
4081249" "5073238" 0 0 2006
2 "
4081249" "5073238" 0 0 2015
2 "
4081249" "5073238" 0 0 2018
2 "
4081249" "5073238" 0 0 2014
2 "
4081249" "5073238" 0 0 2013
2 "
4081249" "5073238" 0 0 2010
2 "
4081249" "5073238" 0 0 2001
2 "
4081249" "5073238" 0 0 2002
2 "
4081249" "5073238" 0 0 2019
3 "
4081249" "5851601" 0 1 2017
3 "
4081249" "5851601" 0 0 2002
3 "
4081249" "5851601" 0 0 2003
3 "
4081249" "5851601" 0 0 2019
3 "
4081249" "5851601" 0 0 2008
3 "
4081249" "5851601" 0 0 2015
3 "
4081249" "5851601" 0 0 2005
3 "
4081249" "5851601" 0 0 2007
3 "
4081249" "5851601" 0 0 2009
3 "
4081249" "5851601" 0 0 2010
3 "
4081249" "5851601" 0 0 2016
3 "
4081249" "5851601" 0 0 2018
3 "
4081249" "5851601" 0 0 2011
3 "
4081249" "5851601" 0 0 2006
3 "
4081249" "5851601" 0 0 2013
3 "
4081249" "5851601" 0 0 1999
3 "
4081249" "5851601" 0 0 2000
3 "
4081249" "5851601" 0 0 2001
3 "
4081249" "5851601" 0 0 2004
3 "
4081249" "5851601" 0 0 2012
3 "
4081249" "5851601" 0 0 2014
4 "
4081249" "6004384" 0 1 2018
4 "
4081249" "6004384" 0 0 2003
4 "
4081249" "6004384" 0 0 2002
4 "
4081249" "6004384" 0 0 2016
4 "
4081249" "6004384" 0 0 2007
4 "
4081249" "6004384" 0 0 2010
4 "
4081249" "6004384" 0 0 1999
4 "
4081249" "6004384" 0 0 2005
4 "
4081249" "6004384" 0 0 2000
4 "
4081249" "6004384" 0 0 2012
4 "
4081249" "6004384" 0 0 2013
4 "
4081249" "6004384" 0 0 2015
4 "
4081249" "6004384" 0 0 2014
4 "
4081249" "6004384" 0 0 2011
4 "
4081249" "6004384" 0 0 2004
4 "
4081249" "6004384" 0 0 2017
4 "
4081249" "6004384" 0 0 2008
4 "
4081249" "6004384" 0 0 2019
4 "
4081249" "6004384" 0 0 2001
4 "
4081249" "6004384" 0 0 2009
4 "
4081249" "6004384" 0 0 2006
5 "
4081249" "765050" 1 1 2018
5 "
4081249" "765050" 1 0 2002
5 "
4081249" "765050" 1 0 2016
5 "
4081249" "765050" 1 0 2011
5 "
4081249" "765050" 1 0 2010
5 "
4081249" "765050" 1 0 2019
5 "
4081249" "765050" 1 0 2005
5 "
4081249" "765050" 1 0 2009
5 "
4081249" "765050" 1 0 2013
5 "
4081249" "765050" 1 0 2006
5 "
4081249" "765050" 1 0 2003
5 "
4081249" "765050" 1 0 2015
5 "
4081249" "765050" 1 0 2004
5 "
4081249" "765050" 1 0 2001
5 "
4081249" "765050" 1 0 2008
5 "
4081249" "765050" 1 0 2012
end
[/CODE]
------------------ copy up to and including the previous line ------------------

Listed 100 out of 20286 observations
Use the count() option to list more



Now my question: I am interested in having a measure of closing triads (closing structural holes). It occurs if for example: A and B have a tie (relation) and B and C have a tie (relation) in t=0. If then a tie is further created between A and C in t=1, I would consider the triad closed (Simmelian).
What I would like to have is a dummy for either owner or charterer in my data that would indicate that he/she was the basis for a closing triad (time variant measure).
I realize such measure is usually used in network analysis, which requires a generation of a matrix based on the two identifiers, year by year, but I hope that maybe this can also be solved with some more complex coding in a panel data structure too.

Thank you so much for your help.
Best regards

Aga

xtabond2 lag sub-option

$
0
0
Dear Statalist,

I am examining quarterly data for an unbalanced panel of 11,000+ banks from 1996:Q1 to 2016:Q4 using Stata/IC. I am using a system gmm model through xtabond2. My regression code is as follows:

Code:
xtset id dateq

xtabond2 LCCF l.LCCF T1RAT SIZE RISK ROE MS MNA COMP POP INCG GDPG UNEM FFR q2_1997- q4_2016, ///
gmm(l.LCCF T1RAT SIZE RISK ROE MS MNA, lag(1 .) collapse) iv(COMP POP INCG GDPG UNEM FFR q2_1997- q4_2016) ///
twostep robust small nodiffsargan
For completeness, variables q2_1997- q4_2016 are dummies for each quarter to introduce time fixed effects. I have included all bank-level variables as endogenous in the -gmm- option, and all other variables as instruments in the -iv- option.

I want to try the model using the following lag specifications:
  • lag(1 .)
  • lag(2 .)
  • lag(3 .)
But when doing so, as in the above code, I get the following error:

Code:
                     J():  3900  unable to allocate real <tmp>[1299463,588]
         xtabond2_mata():     -  function returned error
                 <istmt>:     -  function returned error
If I remove the -collapse- suboption in the -gmm- option, with the following code:

Code:
xtset id dateq

xtabond2 LCCF l.LCCF T1RAT SIZE RISK ROE MS MNA COMP POP INCG GDPG UNEM FFR q2_1997- q4_2016, ///
gmm(l.LCCF T1RAT SIZE RISK ROE MS MNA, lag(1 .)) iv(COMP POP INCG GDPG UNEM FFR q2_1997- q4_2016) ///
twostep robust small nodiffsargan
I get the following error:

Code:
                     J():  3900  unable to allocate real <tmp>[1299463,588]
         xtabond2_mata():     -  function returned error
                 <istmt>:     -  function returned error

Why do these errors occur? xtabond2 seems very limited the detail of its error reporting.

Finding Pairs within a column

$
0
0
Dear Statalists,

my dataset is about directors and which companies they work for and looks like this:

Company_ID Director_ID Term Begin Term End new_app
40416 1 1977 1999 0
15456 1 1983 2013 0
76085 1 1994 2005 0
44601 2 1975 2005 0
15720 2 1988 2002 0
86594 2 1999 2005 1
44601 3 1990 2006 0
78172 3 2000 2005 1
87657 3 2000 2009 1
44601 4 1988 2013 0
44601 5 1985 1999 0
40707 5 1991 2003 0
57568 6 1995 2007 0
80316 6 2002 2009 1
52840 7 1987 2009 0
24221 7 1999 2005 1
24221 8 1999 2009 1
52840 9 1970 2005 0
62148 9 1998 2002 1
59459 9 1998 2003 1
24221 9 1999 2004 1
90601 9 2000 2012 1
10137 9 2003 2011 1

The variable "new_app" is 1 whenever the term of a director began between 1996 and 2014, otherwise it is 0.
Now I would like to create "company pairs". That means whenever a director was appointed by a company in the above mentioned time period (new_app = 1), I want to know all other companies he worked for in that year. For example, if we take Director 2, when he was appointed by company 86594 in 1999, he also worked for companies 44601 and 15720, as his terms at those companies ended in 2005/2002. So I need to identify the combinations or pairs of companies. Ideally, the output (only director 2) would look like this:

Company_1 Company_2 Director_ID Year
86594 44601 2 1999
86594 15720 2 1999


Can anyone help me out with this? I´m willing to thank with a small reward!

predicting linear change when dependent variable is log transformed

$
0
0
Im working with a surgical dataset and trying to predict whether a particular technique (doing the operation under local anesthesia rather than general anesthesia) is faster in terms of the total operative time. As expected, the dependent variable (time) is quite skewed and this is fixed nicely when I use the natural ln transformation of the total time. I run a linear regression as follows:

variables
lntor = ln of the operative time
i.local = whether the surgery was done under local or general anesthesia
age = patient age
i.comorbid = a comorbidity score

reg lntor i.local age i.comorbid

the beta coefficient for i.local is -0.12 which I interpret as a semi-elasticity indicating that doing the surgery under local anesthesia reduces total operative time by 12%

I'd like to then know what the actual change in minutes for operative time is when the surgery is done under local anesthesia. I've tried using the margins command:

margins, at(age=(18(5)100)) dydx(local)

but this doesn't really seem to work. How can I get the unit change in y for a unit change in x (change in operating time for having surgery under local vs general) when the dependent variable is ln transformed for the regression?
Viewing all 72862 articles
Browse latest View live