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

logit model yield too high coefficient

$
0
0
I ran a logit model
Code:
 egen Banks=group(V)
[/CODE] logit Collateraldummy Age Numberofemployees Totalassets Corporationdummy Profitability Leverage Loansize Maturity GDPGrowth Duration Housebank if Loantype=="LC", vce (cluster Banks)
Code:
 
on the following data: 
input float Collateraldummy int Age byte Numberofemployees long Totalassets float Corporationdummy double(Profitability Leverage) long Loansize byte Maturity double(GDPGrowth Duration) byte Housebank str6 Loantype str14 V
1   8 28 1500 1               .0625 .95 475 10 .015                  0 0 "Credit" "Volksbank A"  
0   8 28 1500 1               .0625 .95 475 10 .015                  0 0 "Credit" "Förderbank A"
1   6 15  500 1               .0875  .5 150 10 .015               5.75 1 "Credit" "Volksbank B"  
1   6 15  500 1               .0875  .5  30  1 .015               5.75 1 "LC"     "Volksbank B"  
1   6 15  500 1               .0875  .5  20  1 .015                  6 1 "LC"     "Volksbank B"  
1  23 10  387 0   .0343558282208589 .72  80  1 .022                 10 1 "LC"     "Volksbank B"  
1  24 10  415 0  .05060240963855422 .77  80  1 .022                 11 1 "LC"     "Volksbank B"  
1  25 10  400 0  .03529411764705882  .9 120  1 .015                 12 1 "LC"     "Volksbank B"  
0  24 10  415 0  .05060240963855422 .77  60  6 .022                  1 0 "Credit" "Volksbank A"  
1  15 25  800 1  .03428571428571429  .2 100  1 .015  4.666666666666667 0 "LC"     "Private bank A"
1  15 25  800 1  .03428571428571429  .2 620 20 .015                  0 0 "Credit" "Sparkasse B"  
1  15 25  800 1  .03428571428571429  .2 230  3 .015                  5 0 "LC"     "Sparkasse A"  
0   7  8  130 0  .23333333333333334  .4  50 10 .015               4.75 1 "Credit" "Förderbank A"
0   1  3   60 0                   0   0  20 10 .005                  0 1 "Credit" "Förderbank A"
0   7  8  130 0  .23333333333333334  .4  15  3 .022                  3 0 "LC"     "Private bank A"
1  20 12  450 1              .08125 .26  50 10 .015 10.083333333333334 0 "Credit" "Volksbank B"  
1  18 12  462 1   .0819277108433735 .32 125  5 .022                  8 0 "Credit" "Volksbank B"  
1  19 12  438 1  .07549668874172186  .3 100  5 .022                  0 0 "Credit" "Private bank B"
1  20 12  450 1              .08125 .26  15  1 .015                 10 0 "LC"     "Volksbank B"  
1  19 12  438 1  .07549668874172186  .3  15  1 .022                  9 0 "LC"     "Volksbank B"  
1  18 12  462 1   .0819277108433735 .32  15  1 .022                  8 0 "LC"     "Volksbank B"  
1  19 12  438 1  .07549668874172186  .3 120  1 .022                 10 0 "LC"     "Sparkasse A"  
1  18 12  462 1   .0819277108433735 .32 120  1 .022                  9 0 "LC"     "Sparkasse A"  
0  20 12  450 1              .08125 .26  10  1 .015 10.583333333333334 0 "LC"     "Sparkasse A"  
1  15 10  320 1                 .08 .55  70  6 .015                  7 0 "Credit" "Sparkasse A"  
1  15 10  320 1                 .08 .55 100  5 .015  5.166666666666667 0 "Credit" "Private bank B"
1  10 12  277 1              .09375  .6 150  4 .015  5.083333333333333 1 "Credit" "Sparkasse A"  
1  18 25  720 1  .11388888888888889 .45 350  3 .022                 12 1 "Credit" "Sparkasse A"  
0  20 25  695 1                .105 .45 300  6 .015                 14 1 "Credit" "Sparkasse A"  
1   3  3  248 1                 .11 .44  30  4 .017                  0 0 "Credit" "Private bank A"
1   4  3  250 1  .08333333333333333  .5  50  5 .022               1.33 0 "Credit" "Private bank B"
0   3  3  248 1                 .11 .44   8  1 .017                  0 0 "LC"     "Volksbank A"  
0   4  3  250 1  .08333333333333333  .5   8  1 .022                  1 0 "LC"     "Volksbank A"  
0   4  3  250 1  .08333333333333333  .5  10  3 .022              1.083 0 "LC"     "Volksbank C"  
1   2 25  462 1 .022857142857142857 .45 100  1 .022                  0 0 "LC"     "Volksbank C"  
1   3 29  450 1 .027105263157894736  .5 200  3 .022  .5833333333333334 0 "LC"     "Volksbank C"  
1   3 29  450 1 .027105263157894736  .5 100  1 .022                  1 0 "LC"     "Volksbank C"  
1   2 25  462 1 .022857142857142857 .45 250  5 .022                  0 0 "Credit" "Private bank B"
1   4 29  440 1                .025  .5 200  5 .015 1.4166666666666667 0 "Credit" "Private bank B"
1   7  9  360 1  .18795180722891566 .25  15  1 .017                  5 1 "LC"     "Volksbank A"  
1   8  9  350 1  .18620689655172415 .25  25  1 .022                  6 1 "LC"     "Volksbank A"  
1   9  9  345 1  .18604651162790697  .3  15  1 .022                  7 1 "LC"     "Volksbank A"  
1  45 14 1000 0  .07931034482758621  .6 350  7 .005                 15 1 "Credit" "Volksbank A"  
0  50 15 1050 0  .06666666666666667  .7 300 10 .015                 20 1 "Credit" "Volksbank A"  
1  45 14 1000 0  .07931034482758621  .6 150  1 .005                 15 1 "LC"     "Volksbank A"  
1  46 15  970 0  .06785714285714285  .7 150  1 .022               16.5 1 "LC"     "Volksbank A"  
1  47 15  960 0  .06779661016949153  .7 150  1 .017              17.75 1 "LC"     "Volksbank A"  
1   7  3  350 0                .125  .5  20  1 .015                  7 1 "LC"     "Sparkasse B"  
1   7  3  350 0                .125  .5  15  5 .015                  7 1 "Credit" "Sparkasse B"  
0  25 25  500 1  .18181818181818182  .8 150 10 .015                 15 1 "Credit" "Sparkasse A"  
0  25 25  500 1  .18181818181818182  .8 400 15 .015                 15 1 "Credit" "Sparkasse A"  
0  25 25  500 1  .18181818181818182  .8  50  1 .015                 15 1 "LC"     "Sparkasse A"  
0  40 25  620 0                 .15  .2 150 10 .015                 20 1 "Credit" "Sparkasse A"  
0  40 25  620 0                 .15  .2  50  1 .015                 20 1 "LC"     "Sparkasse A"  
0  35 12  380 1  .06666666666666667  .3  25  5 .015                 15 1 "Credit" "Sparkasse A"  
1   4  7  400 0   .1368421052631579 .25 300  5 .017                  3 1 "Credit" "Volksbank A"  
0   7  9  425 0                .123  .2 250  7 .015                  6 1 "Credit" "Volksbank A"  
1   4  7  400 0   .1368421052631579 .25  50  1 .017                  3 1 "LC"     "Volksbank A"  
1   5  8  415 0  .14358974358974358  .2  80  1 .022  4.333333333333333 1 "LC"     "Volksbank A"  
1   6  9  410 0  .13368983957219252  .2  80  1 .022  5.333333333333333 1 "LC"     "Volksbank A"  
1   7  9  425 0                .123  .2  80  1 .015                  6 1 "LC"     "Volksbank A"  
1 102  6  370 0  .14285714285714285 .42  80  5 .022                 23 1 "Credit" "Sparkasse A"  
1 102  6  370 0  .14285714285714285 .42  30  1 .022                  8 0 "LC"     "Sparkasse B"  
1 103  6  375 0  .13953488372093023 .45  45  1 .022               8.75 0 "LC"     "Sparkasse B"  
0 102  6  370 0  .14285714285714285 .42  80  5 .022                  0 0 "Credit" "Förderbank B"
0  17 28 3500 1  .05495652173913043 .38 500 10 .005                 14 1 "Credit" "Sparkasse A"  
0  22 30 3625 1                 .05  .4 400  7 .022                  4 0 "Credit" "Private bank A"
1  22 30 3625 1                 .05  .4  60  2 .022                  5 0 "LC"     "Private bank B"
1  22 30 3625 1                 .05  .4  50  2 .022 .16666666666666666 0 "LC"     "Private bank B"
0  18 15 3100 1  .06538461538461539  .5 150  3 .018                  5 0 "Credit" "Private bank A"
0  18 15 3100 1  .06538461538461539  .5 130  4 .018                  4 0 "Credit" "Private bank B"
0  18 15 3100 1  .06538461538461539  .5  50  2 .018                  4 0 "LC"     "Private bank B"
1  26 35 2650 1                 .09 .21 300  5 .022                 22 1 "Credit" "Volksbank A"  
1  27 35 2710 1  .09278350515463918 .28 250  7 .017                 23 1 "Credit" "Volksbank A"  
0  29 33 2665 1               .0875 .25  50  9 .022              25.25 1 "Credit" "Volksbank A"  
0  30 33 2700 1  .08297872340425531 .25  80 10 .015 26.333333333333332 1 "Credit" "Volksbank A"  
1  27 34 2710 1  .09278350515463918 .28  80  1 .017 23.166666666666668 1 "LC"     "Volksbank A"  
1  17 26 1980 1   .0893939393939394 .26 325 10 .022                 16 1 "Credit" "Volksbank A"  
0  19 26 2050 1  .08941176470588236 .31 150  8 .022 18.333333333333332 1 "Credit" "Volksbank A"  
0  20 26 1930 1  .08857142857142856 .33 220  5 .015 19.166666666666668 1 "Credit" "Volksbank A"  
0  19 26 2050 1  .08941176470588236 .31  80  1 .022 18.166666666666668 1 "LC"     "Volksbank A"  
end
To interprete the coefficients I ran the margin command:
Code:
margins, dydx(*) atmeans
and I get for profitability and for GDPGrowth a way too high coefficient. It doesnt make any sense that a one percent increase in GDP would lead to an 161% decrease in the likelihood of collateral incidence. Does anybody have an idea of why the coefficients are so large?

Multivariate GARCH models - help needed with implementation and interpretation

$
0
0
For a research project, I'm investigating the connectedness between major financial markets from an econometric point of view.

I've identified that using a multivariate GARCH model fits my data and provides the best analysis to my research project. However, I need some help with implementing this model in Stata.

Using log daily returns of the FTSE 100, S&P 500 and the CSI 300 indices, I've attempted to run a multivariate CCC-GARCH(1,1) model with the following code:
mgarch ccc (FTSE100 = L.FTSE100) (SP500 = L.SP500) (CSI300 = L.CSI300), arch(1) garch(1)
Above, I believe I have written each of the mean equations of the 3 variables as the following:



Then the Stata output:





Following this, I wanted to know if I have correctly specified the multivariate GARCH model in Stata, and if so, how to interpret the results as the coefficients and constants in the GARCH model.

Thanks.

Merging two datasets within the interval of dates

$
0
0
Dear Stata Users,

This post relates to the previous one, I was not clear enough on that. I need to merge "data1" to "data2" so that date in "data1", which is "facilitystartdate" lies between dates in "data2" which are "start" and "end". For that I used the follwing command:

Code:
use data2 
 rangejoin facilitystartdate start end using "D:\Research\date1.dta", by(lenderid)
The problem is as follows. There are some "gvkey"s in data1 (for example: 1034, 1038, 1045, 1075.., etc.) that correspond to "lenderid"s that are in data2, but not in data1. So, I would assume that these gvkey should not appear in the merged sample. How come this is possible?

I attach .csv (origninal files). Please, help me with this issue.



Troubles with ttest and bysort-option

$
0
0
Hello Statalist,

I have the following data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(Sec Unit mean_sec) float(mean_end mean_start diff)
12 2215 2 3 4 -1
13 2215 2 3 4 -1
14 2216 4 5 6 -1
15 2216 4 5 6 -1
16 2216 4 5 6 -1
17 2217 3 4 5 -1
18 2217 3 4 5 -1
19 2218 3 6 7 -1
20 2218 3 6 7 -1
21 2218 5 6 7 -1
22 2218 5 6 7 -1
23 2218 5 6 7 -1
24 2219 5 4 5 -1
25 2219 4 4 5 -1
end
label values Unit v2_Num
label def v2_Num 2215 "05-002", modify
label def v2_Num 2216 "05-003", modify
label def v2_Num 2217 "05-004", modify
label def v2_Num 2218 "05-005", modify
label def v2_Num 2219 "05-006", modify


The dataset is much larger, but those are the relevant variables.
It is based on seconds.
'Unit' defines multiple units of various length. Mean_start is the mean for the first second of a unit, mean_end of the last.
'diff' is mean_ende minus mean_start. I would like to run a dependent ttest to test whether this difference is significant, seperate for each unit.

What I did is:
bysort Unit: ttest mean_ende == mean_start

It runs, but it leaves the field for the t-value empty and therefore also for the p-value.

Does anybody know what went wrong?

Thank you!

Interpreting Univariate Difference-in-Difference Results

$
0
0
Hi, I'm doing a difference-in-difference analysis on how the ESG reform in Hong Kong affected firm value. My study period ranges from 2013-2017 with the shock happening in 2016.

I have performed a univariate difference-in-difference but I'm not sure how to interpret the results.
The code I used was: diff tobinq_w if fisc_year>=2014 & fisc_year<=2017, t( treatment_vol) p( crisis)
treatment_vol is a dummy variable that gets a value of 1 if firms have complied with the reform and crisis is a dummy variable that gets a value of 1 if the years are 2016 and 2017
These are my results
DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS
Number of observations in the DIFF-IN-DIFF: 6174
Before After
Control: 2846 2906 5752
Treated: 160 262 422
3006 3168
--------------------------------------------------------
Outcome var. | tobin~w | S. Err. | |t| | P>|t|
----------------+---------+---------+---------+---------
Before | | | |
Control | 1.888 | | |
Treated | 1.317 | | |
Diff (T-C) | -0.570 | 0.168 | -3.40 | 0.001***
After | | | |
Control | 1.798 | | |
Treated | 1.515 | | |
Diff (T-C) | -0.283 | 0.133 | 2.12 | 0.034**
| | | |
Diff-in-Diff | 0.288 | 0.215 | 1.34 | 0.180
--------------------------------------------------------
R-square: 0.00
* Means and Standard Errors are estimated by linear regression
**Inference: *** p<0.01; ** p<0.05; * p<0.1
Diff (T-C) is significant for before and after, so does that mean the reform had a positive effect on firm value?

really appreciate any help i can get! Thanks in advance

Is there a way to checking if two n-dimensional &quot;matrices&quot; are equal without writing a loop? (n&gt;2)

$
0
0
I am writing code that involves three dimensional spatial data.

I need to check if two 3D matrices, which represent values at (x,y,z) spatial locations, are equal.

If use an associative array to handle the 3 dimensions, it seems like I need to use a loop.

The simple example below illustrates the issue for a one-dimensional associative array.

Code:
: A=asarray_create("real",1)

: 
: B=asarray_create("real",1)

: 
: asarray(A,1,42)

: 
: asarray(B,1,42)

: 
: A==B
  0

: 
: a=asarray(A,1)

: 
: b=asarray(B,1)

: 
: a==b
  1

General Question

$
0
0
Hello experts, Kindly guide me how to export data from stata to excel file.

Programming

$
0
0
Hello experts, Kindly let me know how to match merge two or more files. I need the codes. Thanks

Graphing interaction terms

$
0
0
I have fitted a two - level cross-classified logistic models using runmlwin (mcmc). I would like to plot/graph an interaction between two variables but I have not been able to find an alternative to the margins command. This is the regression with factor notation that I run:

Code:
quietly runmlwin def1 cons c.Age##c.Age  0.employment i.Educ#i.employment dmarital1  i.practice i.Educ#i.practice  i.dev1 i.Educ#i.dev1 divorce i.class income i.Nchildren , level2(Period:cons) level1(Cohort:) discrete(dist(binomial) link(logit) denom(cons)) nopause

runmlwin def1 cons c.Age##c.Age  0.employment i.Educ#i.employment dmarital1  i.practice i.Educ#i.practice  i.dev1 i.Educ#i.dev1 divorce i.class income i.Nchildren, level2(Period:cons) level1(Cohort:) discrete(dist(binomial) link(logit) denom(cons)) mcmc(cc) initsprevious nopause
runmlwin, noheader noretable or
I then removed factor notation and added all the dummies, then set all variables to zero except the two variables of interest (education x employment interactions) and attempted to predict the outcome + SE :


Code:
quietly runmlwin def1 cons Age agesq  demploy1 deduc2#demploy1 deduc3#demploy1 deduc4#demploy1 dmarital1  dprac2 dprac3 demploy1 deduc2#dprac1 deduc2#dprac2  deduc2#dprac3 deduc3#dprac1 deduc3#dprac2  deduc3#dprac3     deduc4#dprac1 deduc4#dprac2  deduc4#dprac3  devd1 deduc2#devd1 deduc3#devd1 deduc4#devd1 divorce devd1 dclass2 dclass3 income dchild2 dchild3 dchild4 dchild5, level2(Period:cons) level1(Cohort:) discrete(dist(binomial) link(logit) denom(cons)) nopause

runmlwin def1 cons Age agesq  demploy1 deduc2#demploy1 deduc3#demploy1 deduc4#demploy1 dmarital1  dprac2 dprac3 demploy1 deduc2#dprac1 deduc2#dprac2  deduc2#dprac3 deduc3#dprac1 deduc3#dprac2  deduc3#dprac3     deduc4#dprac1 deduc4#dprac2  deduc4#dprac3  devd1 deduc2#devd1 deduc3#devd1 deduc4#devd1 divorce devd1 dclass2 dclass3 income dchild2 dchild3 dchild4 dchild5, level2(Period:cons) level1(Cohort:) discrete(dist(binomial) link(logit) denom(cons)) mcmc(cc) initsprevious nopause
runmlwin, noheader noretable or

local unwanted = "Age agesq dmarital1 dprac2 dprac3 devd1 divorce dclass2 income dchild2 dchild3 dchild4 dchild5 "
foreach var in `unwanted' {
    replace `var' = 0
}

predict yhat
predict yhat_se, stdp
gen yhat_lb = yhat - 1.96 * yhat_se
gen yhat_ub = yhat + 1.96 * yhat_se
The predict yhat returns the following error:
variable _0b_deduc2_1_demploy1 not found


For reference, I am attempting to achieve this:

Code:
margins, at(Educ=(0(1)3)) over(employment)
marginsplot

Multiple imputation with panel data

$
0
0
Hello,

I want to use a multiple imputation panel dataset (originally in SPSS) in Stata. To do so, I wrote the following do-file:

mi import flong, m(Imputation_) id(nomem_encr year)
egen id=group(nomem_encr)
mi xtset id year
panel variable: id (unbalanced)
time variable: year, 2008 to 2018, but with gaps
delta: 1 unit

So far, everything works. However, when I ask for xtdes, I get the following error: repeated time values within panel.
What else should I do to recognize my dataset as both a multiple imputation dataset and a panel dataset?

Also, when I ask for xttab or xtreg, the data is grouped by id, but the different imputations are not taken into account. Using 'mi estimate: xttab' does not solve my problem, as I then get the error that xttab is not officially supported by mi estimate. How can I make sure Stata xttab and xtreg take into account the multiple imputations as well as the multiple observations nested in respondents?

Thanks.

chow test for mixed (growth-curve) model

$
0
0
Hi,

I have a question about the chow test for comparing coefficients in mixed models.

On this Stata FAQ pages, it talks about the chow test:

"You can include the dummy variables in a regression of the full model and then use the test command on those dummies. You could also run each of the models and then write down the appropriate numbers and calculate the statistic by hand—you also have access to functions to get appropriate p-values."

I am running two growth-curve models by males and females separately using stata mixed procedure. I then use chow test to see if the coefficients for the two mixed models are significantly different by males and females.

Is chow test appropriate for testing if the coefficients for the two mixed models are significantly different by males or females?

In my code:

g2 is my gender variable with g2: 1=female; 0=male; ctage1 is an age variable; I am running a cubic growth curve model.

My code for mixed model:

Code:
mixed cesd3w c.ctage1##i.g2 c.ctage1#c.ctage1##i.g2  ///
                       c.ctage1#c.ctage1#c.ctage1##i.g2 ///
                       [pweight=w1wt_fmch3] || aid: ctage1, pweight(schwt1) ///
                       pwscale(size) nolog cov(un) mle variance
The result for the mixed model:

Code:
Mixed-effects regression                        Number of obs     =     62,976
Group variable: aid                             Number of groups  =     18,185

                                                Obs per group:
                                                              min =          1
                                                              avg =        3.5
                                                              max =          5

                                                Wald chi2(7)      =     378.24
Log pseudolikelihood =  -20658221               Prob > chi2       =     0.0000

                                                (Std. Err. adjusted for 18,185 clusters in aid)
-----------------------------------------------------------------------------------------------
                              |               Robust
                       cesd3w |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
------------------------------+----------------------------------------------------------------
                       ctage1 |   .0537449   .0158186     3.40   0.001     .0227409    .0847488
                         1.g2 |   .6205963   .0732295     8.47   0.000     .4770691    .7641235
                              |
                  g2#c.ctage1 |
                           1  |   .0001431   .0232488     0.01   0.995    -.0454237      .04571
                              |
            c.ctage1#c.ctage1 |  -.0050771   .0013704    -3.70   0.000     -.007763   -.0023912
                              |
         g2#c.ctage1#c.ctage1 |
                           1  |  -.0034937   .0020319    -1.72   0.086    -.0074762    .0004888
                              |
   c.ctage1#c.ctage1#c.ctage1 |   .0001352   .0000342     3.95   0.000     .0000682    .0002023
                              |
g2#c.ctage1#c.ctage1#c.ctage1 |
                           1  |   .0001173   .0000511     2.30   0.022     .0000172    .0002173
                              |
                        _cons |   .9459049   .0474442    19.94   0.000      .852916    1.038894
-----------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
                             |               Robust           
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
aid: Unstructured            |
                 var(ctage1) |   .0031306   .0003701       .002483     .003947
                  var(_cons) |   1.315501   .0724852      1.180835    1.465525
           cov(ctage1,_cons) |  -.0402105   .0046329     -.0492908   -.0311303
-----------------------------+------------------------------------------------
               var(Residual) |   1.926895   .0369594        1.8558    2.000713
------------------------------------------------------------------------------
My chow test:

Code:
 contrast g2 g2#c.ctage1  g2#c.ctage1#c.ctage1 g2#c.ctage1#c.ctage1#c.ctage1
My results for the chow test:

Code:
Contrasts of marginal linear predictions

Margins      : asbalanced

-----------------------------------------------------------------
                              |         df        chi2     P>chi2
------------------------------+----------------------------------
cesd3w                        |
                           g2 |          1       71.82     0.0000
                              |
                  g2#c.ctage1 |          1        0.00     0.9951
                              |
         g2#c.ctage1#c.ctage1 |          1        2.96     0.0855
                              |
g2#c.ctage1#c.ctage1#c.ctage1 |          1        5.28     0.0216
-----------------------------------------------------------------


By looking at the results from contrasts, can I say:

(1) the cubic age is statistically different by gender (g2#c.ctage1#c.ctage1#c.ctage1) with P=0.0216?

(2) But the linear and quadratic age are not significantly different by gender (g2#c.ctage1 with p=0.9951; g2#c.ctage1#c.ctage1 with p=0.0856)?

Thank you for your advice!

Alice

Not significant in bivariate chi square or bivariate logistic regression but is in multivariate logistic regresison?

$
0
0
Hi, Ive come across in my analysis results that two independent variables are not significant in bivariate chi square or bivariate logistic regression but become significant in multivariate logistic regression when accompanied by other independent variables? I know multicollinearity is for the opposite but can anyone explain a possible reason for this?

Thanks.

Multilevel modelling: How to predict upper-level outcomes?

$
0
0
Dear all

I have the following problem that I hope to find help with:

My data structure is as follows, with employee-employer links over several years:
y j i yj xj xi
1 1 1 a x f
1 1 2 a x g
1 1 3 a x h
2 1 1 b y f
2 1 2 b y g
2 1 3 b y h
1 2 4 c z l
1 2 5 c z j
1 2 6 c z n
2 2 1 d xy f
2 2 4 d xy I
2 2 5 d xy j
Where, i=individuals, j=firms, y=year, yj = y-values on the j-level (continous variable), xj = x-values

My aim:
To explain an y-variable on the j-level (firm-level), for example profitability, from both j-level explanatory variables (for example debt) and individual characteristics (for example gender), to investigate the influence of individuals on firm outcomes.

My problems:
* How do i explain the yj variable, when it's on a higher level than the explanatory variables? For example, for firm j in y 1: the yj (dependent variable) is repeated three times...
* Individuals (i) are nested within firms (j) - but they can also move between firms! For example, in my example above individual 1 moves from firm (j) 1 in year (y) 1 to firm (j) 2 in year (y) 2.
* How do I incorporate into the model the fact that employees are ranked within the firm-year? Within each firm-year I rank employees according to salary, assuming that the highest paid employees have most influence on firm outcomes.

I am looking forward to your valuable inputs!

Best,
Morten Jensen

How to Add Deterministic Trend to Panel Data?

$
0
0
Hello,

I have a panel data with 115 countries and 20 years. I did unit root test in all my independent variables and the dependent. From my results, I have the presence of unit root in some of the independent and the dependent. According to the literature that I'm following, I need to add a deterministic trend to my model.

This is my original regression:

Code:
xi:reg reconsumption lngdppppcte2011lag1 manufacturinglag1 lnoilpricelag1 energyimportslag1 leftlag4 i.country, robust
How do I add a deterministic trend to panel data?

I thought that adding
Code:
i.year
was enough but I was told that is not the correct way. Now I don't know how to proceed.


Thanks in advance!


esttab, eststo and appendmodels

$
0
0
Dear all, I am tabulating different dependent variables in consecutive rows (not consecutive columns as it is the default for esttab) and I'm keeping only one explanatory variable. I want two columns per model, one with few controls, the other one with more controls. I'm using the option "appendmodels" so every dependent variable is showed in a row. I would like the explanatory variable I'm keeping to have the label/name of the dependent variable. I have tried to use rename and change the label of the explanatory variable every time I run the regression but it keeps only the last change and not a different label for each regression. See an example of what I'm doing below. I have three different rows with the variable foreign, but I want instead the name of the dependent variable used in each specification. In the example I would like to change "foreign" for the name of the dependent variables (price and weight). Any help would be appreciated. Thanks, Lina.

sysuse auto, clear
eststo r1: reg price foreign
eststo r2: reg price foreign head

eststo r3: reg weight foreign
eststo r4: reg weight foreign head

eststo nocontrols: appendmodels r1 r3
eststo controls: appendmodels r2 r4

esttab controls nocontrols, replace keep(foreign)






Parameter constraints for MLE model

$
0
0
Dear forum guests!

I need to introduce a range constraint for the sum on parameters in MLE model. This is necessary for economics reasons. At the moment, I have two ways to do that, inside of do-file. One is to add constraint directly to the sum of parameters, second one is to add constraint to every parameter separately. In last case, the sum is automatically constrained. I give you some example.

Suppose the parameters are b1, b2 and b3. Now, let's suppose that the sum is positive and less or equal to 1.5. Also, the sum is marked with the variable "scale". So, scale = 1.5*invlogit(b1+b2+b3), which means that 0≤scale≤1.5. In this case, no additional parameters.

The second option means I have to add some additional parameters, something like b01=invlogit(b1), b02=0.2*invlogit(b2) and b03=0.3*invlogit(b3). So, in that case scale=b01+b02+b03.
The choice of these multipliers is based on alternative estimates of parameters with another model. There is also some space left there.

Now becomes the tricky part. These two ways act very differently. The first option gives very realistic (economically) results. The sum of parameters is around 1.1. The second option gives not very realistic results, these parameters are not statistically significant, also likelihood has difficulties in converging.

But, I have been told, that this second option is correct and the first one is not? The reason, why this first option is not correct, is exactly because of the lack of these constraints directly for parameters. So, these constraints must be present in likelihood expression also, It is not enough that only the sum has constraints. In this case this is already some other model.
Is it really so?
Why should I use three constraints, when only one seems already enough? I would prefer to let the parameters vary freely and only restrict the range of their sum. Moreover, there is possibility to use "constraint" command separately, before the command "ml model". Only problem is that inequality constraint is not possible. But, in this case this is also only for the sum and is perfectly correct.
I am very grateful if anyone can explain and advise on this topic.

Looking for alternatives to outreg2

$
0
0
Dear Statalist,

I am trying to do some descriptives and to export the table to a word document. I usually use outreg2 command, however, it seems that is not properly working (I am using Stata 15.1). This is the command I am trying
Code:
bys offshoring: outreg2 using "firm_descriptives.doc" ,  sum(log) eqkeep(mean sd N) keep(offshoring coopera internalRD )
invalid syntax
r(198);
I am pretty sure this command has worked in the past. I am also interested in reporting another descriptive but this time for the panel structure: xtsum...

Have anyone any idea of what am I doing wrong with the outreg2 command; or any other command that allow me to export those descriptive to Word?

Any help will be much appreciated.

Writing paragraphs using putdocx text

$
0
0
Hi

I'm trying to use putdocx to automate a report. When writing long paragraphs, it seems I can't go into the next line. I once found a sign similar to /* */ (but a slightly different symbol) to break inside the string and was successful but I can no longer remember or find what the sign is. Does anyone know?

E.g.
putdocx text ("An electronic data capture system is being used for the x trial. This system groups electronic Case Report Forms (eCRFs) in to time-point based Events etc... ")

Would like to do:
putdocx text ("An electronic data capture system is being used for the x trial.
This system groups electronic Case Report Forms (eCRFs) in
to time-point based Events etc... ")

Thanks

Frequency table for multiple variables

$
0
0
Dear all,

As a fairly new user of Stata, I would appreciate any suggestions to create a frequency table of my data. I have already searched through the forum and Google, but I cannot seem to figure out a solution.

I have developed a questionnaire to ask people how often they have consumed foods from a certain food group (my variables). They can indicate: 0 (never), 2, 4, 13, 14 or 30 days (each day) over the past month.

To make it simple, my dataset looks similar to this:
Variables: 1_grains, 2_meat, 3_vegetables (etc.)
Response categories: 0, 2, 4, 13, 24, 30
n = 80.

Now I would like to know how many of my respondents have consumed at least 2 days of the month (response category ≥2) a food from a food group. I can do this one by one with tabulate:

. tab 1_grains if 1_grains > 0 Array

So 77 out of 80 people have eaten a food from the food group "grains". So I can either do this all manually, but I assume there must be an easier way, to create something like this:
Food group n (days consumed > 0) Percentage
1_grains 77 96%
2_meat 30 38%
3_vegetables 45 56%
A next step would be to put these percentages in a graph, but if I can get the numbers and percentages into a table that would already be great.

Thanks in advance for any help on this!

Kind regards,
Brenda

mlogit - coefficent and marginal effects with different sings

$
0
0
Hi,

I am running a multinational logistic regression with the mlogit command. I have noticed that the coefficient of one of the independent variables (a dummy) takes a negative sign, which i interpret as the dummy having a negative impact on the probability of (let's say) outcome 1 with reference to the base outcome.

but when I estimate the marginal effects as follows:

Code:
margins x, post pr (out(1))
I get the opposite result, that is, a change from 0 to 1 in the independent variable has a positive impact on the probability of outcome 1.

Can someone explain to me why that could happen?

Thanks!

Amy

Viewing all 65121 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>