Code:

* Example generated by -dataex-. For more info, type help dataex clear input float(A B C) 0 0 0 1 2 2 0 4 6 0 5 11 0 3 14 2 0 0 0 0 0 0 0 0 1 3 3 0 6 9 0 7 16 2 0 0 end

I've tried several things, for example, if one of the data fields is field_a

generate field_a_temp = 0

replace field_a_temp = 7 if (field_a == "more than 6")and I get a type mismatch error. Same with generate field_a_temp = "", or generate field_a_temp = .

I am a beginner. Thanks for any guidance.

]]>

I am trying to use the doubleb command to estimate a respondent's willingness to accept a certain intervention.

However, I am receiving the following error code:

There is an inconsistency in at least one of your observations.

Check for situations where the response to the first question is yes but the second bid is lo

> wer than the first

or for situations where the response to the first question is no but the second bid is higher

> than the first.

After solving this issue try the command again.

r(498);

The first question (answer1) asks how much the respondent thinks OTHER PEOPLE are WTA for the intervention while the second question (answer2) askes how much the RESPONDENT is WTA for the intervention. The amount in the second question increases or decreases based on the yes/no response to the first question. So it

How can I use a double-bounded model given this structure of the two survey questions?

Is there another STATA package that is more appropriate?]]>

Code:

* Example generated by -dataex-. For more info, type help dataex clear input double id float visit_date 25 21091 25 21091 25 21091 25 21091 25 21091 25 21091 25 21104 25 21104 25 21104 25 21122 25 21122 25 21122 25 21235 25 21325 25 21325 25 21325 25 21355 25 21355 25 21355 25 21388 25 21629 25 21629 25 21629 25 21839 25 21839 25 21875 25 21875 25 21941 25 21941 25 21941 end format %td visit_date

Array

Thank you!

Andrea.

]]>

I am new to this forum and grateful for any help. I am trying to save beta coefficients for each firm-year observation using the following code:

Code:

statsby , by (GlobalCompanyKey FiscalYear) : regress ROA l.ROA Leverage

Is there something wrong with my code?

Please tell me if there is any possible way to get the beta coefficients for each firm-year observation.

Here is the example of my data:

Code:

* Example generated by -dataex-. To install: ssc install dataex clear input long GlobalCompanyKey int FiscalYear float(ROA Leverage) 1004 1989 .06603247 1.0497235 1004 1990 .03895431 .9607902 1004 1991 .02534457 1.0095407 1004 1993 .02273326 1.2039707 1004 1994 .02457176 1.1601875 1004 1995 .036569934 1.1396438 1004 1996 .04347752 .9668201 1004 1997 .05317504 1.2288815 1004 1998 .05734831 1.228687 1004 1999 .04745357 1.1825192 1004 2000 .02640293 1.0629902 1004 2004 .021104025 1.3264303 1004 2005 .035923906 1.315542 1010 1989 .15727852 5.12465 1010 1991 .08937106 4.067188 1010 1993 .06737955 4.0140133 1010 1994 .013883533 3.5789874 1010 1995 .04181962 3.2464075 1010 1996 .04164788 2.865455 1010 1997 .068022504 3.3659716 1010 1998 .020630583 3.0400996 1010 1999 .021692766 2.93682 1010 2000 .021056794 2.83648 1010 2002 .021525996 3.0641944 1010 2003 .07294965 1.8636254 1012 1989 .04127656 1.409283 1013 1989 .11404356 .3019915 1013 1990 .12607272 .3555774 1013 1991 .08910907 .5606665 1013 1992 .08733106 .3215031 1013 1993 .11296393 .27069703 1013 1994 .11673997 .2641129 1013 1995 .09181095 .1765962 1013 1996 .1137708 .24502406 1013 1997 .11624122 .2470821 1013 1998 .11281598 .4223797 1013 1999 .0523967 .339576 1013 2000 .21863745 .3631682 1013 2004 .01148379 1.1660852 1013 2005 .07211726 .9834604 end

TramAnh Nguyen.]]>

I have four models ( dynamic panel models ) :

1- linear model

GDP = β1 FDX + β2 INF + β4 GOV + β5 GFCF + β6 TRD + β7 LBOR

2- model with an interactive term

GDP = β1 FDX + β2 INF + β3 FDX * INF + β4 GOV + β5 GFCF + β6 TRD + β7 LBOR

3- non-linear model :

GDP = β1 FDX + β2 FDX

4- non-linear with interactive term

GDP = β1 FDX + β2 FDX

Where GDP is the dependent variable, FDX is the endogenous variable and INF, GOV, GFCF, TRD and LBOR are the exogenous variables and lagged variables are used as the instrumental variables.

What is the Tow Stage Least Square (2SLS) estimation command for each model, please?

Can I use -xtivreg- with the fe option for the first model? if yes, what about the rest of the models ( 2, 3 and 4)

I would be very grateful for any help

Many Thanks

Badiah]]>

. capture program drop capm

. program define capm, rclass

1. syntax varlist(min=2 max=2 numeric) [if], RFrate(varname)

2. local stockret: word 1 of `varlist´

3. local mktret: word 2 of `varlist´

4. cap drop prem`stock´

5. qui gen prem`stock´=`stockret´-`rfrate´

6. cap drop mktpremium

7. qui gen mktpremium=`mktret´-`rfrate´

8. cap reg prem`stock´ mktpremium `if´

9. if _rc==0 & r(N)>30 {

10. matrix res= r(table)

11. local b1=res[1,1]

12. local b0=res[1,2]

13. local SEb1=res[2,1]

14. local SEb0=res[2,2]

15. local N=e(N)

16. dis "Market beta is " %3.2f `b1´ "; std. error of beta is " %8.6f `SEb1´

17. dis "Alpha is " %8.6f `b0´ "; std. error of alpha is " %8.6f `SEb0´

18. return scalar b1=`b1´

19. return scalar b0=`b0´

20. return scalar SEb1=`SEb1´

21. return scalar SEb0=`SEb0´

22. return scalar N=`N´

23. }

24. end

. qui freduse TB3MS, clear

. qui gen m_Rf = (TB3MS/100)/12

. qui gen m_rf = ln(1 + m_Rf)

. qui gen period =mofd(daten)

. format period %tm

. qui tsset period

. cap getsymbols ^GSPC CAG, fy(2014) freq(m) yahoo clear price(adjclose)

. qui merge 1:1 period using rfrate, keepusing(m_rf)

. qui drop if _merge!=3

. qui drop _merge

. capm r_CAG r__GSPC, rfrate(m_rf)

I get "invalid name r(198);" error. May I ask you ladies and gentlemen to tell me what is wrong? I tried with different .do files with and without saving and I still face the same problem. The code comes from a conference on measuring abnormal returns of stock and everything comes from a file shares with audience.

Best Regards,

Rafał]]>

I was looking to suppress the iterlog when running mlogit. I'm aware of set iterlog, but ran into an issue with this when using Stata 14. Is there another way I could go about doing this?

Thanks,

Joel

]]>

Dataex:

```

dataex BORO

----------------------- copy starting from the next line -----------------------

Code:

* Example generated by -dataex-. For more info, type help dataex clear input int BORO 3 2 1 3 1 3 3 4 1 3 3 3 3 3 3 3 3 3 3 3 3 3 1 1 3 3 3 3 1 4 3 1 1 2 3 4 4 4 1 3 2 2 2 3 3 4 4 4 3 2 2 3 5 4 2 3 4 3 1 1 1 3 4 1 4 1 3 4 4 1 2 3 1 3 3 4 4 1 3 1 1 4 3 1 1 1 4 1 5 2 3 3 2 1 1 1 1 1 1 1 end label values BORO BORO label def BORO 1 "Manhattan", modify label def BORO 2 "Bronx", modify label def BORO 3 "Brooklyn", modify label def BORO 4 "Queens", modify label def BORO 5 "Staten IslAND", modify

Stata code:

```

eststo clear

eststo: estpost tab BORO

esttab using Borough.tex

```

```

Latex code:

{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \begin{tabular}{l*{1}{c}} \hline\hline &\multicolumn{1}{c}{(1)}\\ &\multicolumn{1}{c}{BORO}\\ \hline Manhattan & 120545 \\ & \\ [1em] Bronx & 75824 \\ & \\ [1em] Brooklyn & 176119 \\ & \\ [1em] Queens & 114988 \\ & \\ [1em] Staten IslAND& 19013 \\ & \\ [1em] Total & 506489 \\ & \\ \hline \(N\) & 506489 \\ \hline\hline \multicolumn{2}{l}{\footnotesize \textit{t} statistics in parentheses}\\ \multicolumn{2}{l}{\footnotesize \sym{*} \(p<0.05\), \sym{**} \(p<0.01\), \sym{***} \(p<0.001\)}\\ ```

However, in the Latex output, the table only shows the absolute number of police stops per borough, but NOT the proportion/share for each borough out of total stops.

]]>