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

The stata command for double hurdle model

$
0
0
I used the stata version 16 to implement double hurdle model.
I found 2 commands for implementing the double hurdle model.
1) craggit depvar1 [indepvars1] [if] [in] [weight], second(depvar2
[indepvars2]) [options]
2) dblhurdle depvar [indepvars] [if] [in] [weight], {ll(#)|ul(#)}
[options]

I would like to know how is the difference between these commands?

I would really appreciate the help with this, I am new to STATA!

Waranan Tantiwat

Line sum value over years (more than one value per year)

$
0
0
Hi everyone! I am a student who is very new to STATA and much appreciated if someone could help with the below questions.

I was asked to design an empirical strategy to see whether the share of printing in Venice decline after 1498.

I have 1000 random samples of published material including the cities where they were printed and the print year, during 1475 - 1650. In other words, the two variables are Venice (dummy variable, equals to 1 if the material is printed in Venice) and t (the year of print).

I have used the below codes to generate the variable for the share of printing in Venice per year:

egen venicet = sum(venice), by(t)
gen sample =1
egen total = sum(sample), by(t)
drop sample
gen share = venicet/total

However, this gives me multiple same observations for one year (for example in the table below), and I am not sure how I can then line the change of share over years (keep only one share observation per year), and to create the empirical strategy to see whether the share of printing in Venice decline after 1498. Please give me some suggestions on this, many thanks!!!
Venice t share
1 1479 0.25
0 1479 0.25
0 1479 0.25
0 1479 0.25
1 1484 0.2
1 1484 0.2
0 1484 0.2
0 1484 0.2
0 1484 0.2

Please help me to create a loop to replace missing values to 0

$
0
0
Hi all,

I have a dataset like this
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(newdate dateid) long userid double amount
21297  90 1 1
21299  92 1 2
21303  96 1 3
21304  97 1 1
21305  98 1 4
21306  99 2 1
21306  99 1 9
21307 100 1 1
end
format %td newdate
I have a time-series dataset for thousands of users, and not all users have values (of amount) for all observed days. In fact, on those days, they have values at 0. From the initial dataset, I used the following codes to manually do it for only 2 users.
Code:
* Reshape to WIDE in order to replace missing values to 0
    reshape wide amount, i(newdate dateid) j(userid)
    
    replace amount1 = 0 if amount1 == .
    replace amount2 = 0 if amount2 == .
    list
* Reshape back to LONG
    reshape long
    list, sepby(newdate)
     +--------------------------------------+
     |   newdate   dateid   userid   amount |
     |--------------------------------------|
  1. | 23apr2018       90        1        1 |
  2. | 23apr2018       90        2        0 |
     |--------------------------------------|
  3. | 25apr2018       92        1        2 |
  4. | 25apr2018       92        2        0 |
     |--------------------------------------|
  5. | 29apr2018       96        1        3 |
  6. | 29apr2018       96        2        0 |
     |--------------------------------------|
  7. | 30apr2018       97        1        1 |
  8. | 30apr2018       97        2        0 |
     |--------------------------------------|
  9. | 01may2018       98        1        4 |
 10. | 01may2018       98        2        0 |
     |--------------------------------------|
 11. | 02may2018       99        1        9 |
 12. | 02may2018       99        2        1 |
     |--------------------------------------|
 13. | 03may2018      100        1        1 |
 14. | 03may2018      100        2        0 |
     +--------------------------------------+
I can manually do it with only 2 users, but for thousands of users, I can not.

I know in Stata we can do it with loop but I can not manage to do it myself. Thank you for your help.

Best regards,

Thong Nguyen

Quickest Way to convert Int/Flot to String

$
0
0
Hello there, what would be the easiest and quickest way to convert int or float to string from the command line?

Stata freezing forever after -glm- command*

$
0
0
Hi,

I am running a simple glm model with -link(log)- function, and it makes both Stata 14 and 15 irresponsive in both Windows and Mac.

Code:
glm ff2 i.Age i.Education i.Occ i.Residency , family(binomial) link(log) eform nolog
This doesn't happen if I change the link function to logit. Does anyone have any idea how this can be solved.


Thanks in advance for your insights.

How to use psacalc command with the option mcontrol so that to take fixed-effects as unrelated controls ?

$
0
0
Hello Dear All,

I am trying to use psacalc command in Stata to build an argument for omitted variables bias.

My regression takes the form: "reg Depvar X1 X2 ... Xn i.CODE i.ETHNY i.OCC i.REL i.COL, cluster(IDENTIFIER)" (1).
My will is that psacalc command to consider all the fixed effects (i.CODE i.ETHNY i.OCC i.REL i.COL) as unrelated controls and include them in all the regressions, uncontrolled and controlled ones.

So I run the following command "psacalc delta X1, mcontrol(i.CODE i.ETHNY i.OCC i.REL i.COL)".
But Stata returns the following message "Unrelated control not in regression". I've replaced "mcontrol" by "mcontrols" but it did not work neither.

Question 1: Does someone know what is going please ? How can I implement that correctly please?

In addition, after the regression (1) above, I run the command "psacalc beta X1" and Stata gave me the results attached to this post. My concern is that the beta retuned by the command is 4641.34207 which is too big to me. I was thinking beta should be my estimate on X1, which should not be that big! Or maybe I am wrong ?

Question 2: Does someone know how to clearly interpret the results attached to my post please? For example, what does the "Yes" on the results really mean please ?

Any attempt to explain how psacalc command works properly in general would be very appreciated. Thanks in advance for your kind replies. Sorry if some of my questions seem to be stupid.

Array


Modeling my own line in OLS / scatter graph for residual values?

$
0
0
Hello everyone,
I was just wondering whether it is possible to (1) model my own "pseudo-regress line" in scatter graph and (2) calculate residual values in reference to the modeled line. My problem is that I have a theoretical assumption about what the relationship between variable X and Y and I would like to compare my theoretical expectation (which is represented by the newly created line) to the real data.

Thank you for your help.

graph the predicted probability

$
0
0
Hi guys!

I am totally new with statistics, just started to learn using Stata. On the last class we were learning about linear regressions, predicted probability, logit, margins etc. I am trying to practice but it doesn`t go very well. So before we made this:

/*Graph the predicted probability of Pi with/without a confidence interval*/
quietly logit grade gpa tuce i.psi
margins psi, at(gpa = (2(.1)4) ) atmeans
marginsplot, noci scheme(sj) xtitle("GPA") ytitle("Pr(Y=1)") ///
title("Predicted Probability of Getting An A")

quietly logit grade gpa tuce i.psi
quietly margins psi, at(gpa = (2(.1)4) ) atmeans
marginsplot, scheme(sj) xtitle("GPA") ytitle("Pr(Y=1)") ///
title("Predicted Probability of Getting An A")

I tried to copy these commands to solve an excercise, but it doesn`t really work, can you help make write the right command for these (happymar, female, educ)

1.predicted probability of marital happiness for the female and male over
various years of education (set church=1).

2. substantive effect of gender on the predicted probability
of marital happiness over various years of education (set church=1).

spoiler

$
0
0
[SPOILER]Lets try this[/SPOILER]

Oprobit and marginsplot

$
0
0
We are running an oprobit for a 5-category dependent variable (Y) and would like to have a marginal effect graph for a continuous variable in the form of a graph in Prof. Williams’ “Adjusted Predictions & Marginal Effects for Multiple Outcome Models” https://www3.nd.edu/~rwilliam/xsoc73994/Margins05.pdf

Text and graph reproduced here (pp.4-5):

. mgen, at(age = (20(5)75)) stub(all)
. list allpr1 allpr2 allpr3 allpr4 allpr5 allage in 1/15
. line allpr1 allpr2 allpr3 allpr4 allpr5 allage, scheme(sj) name(pooled)

Array


The continuous independent variable (X1) essentially counts the number of days of a particular event in a country and we cluster around the regions in that country. Note, X2 and X3 are interactions of X1 and a set of dummy variables. The remainder are controls.

When we run the following:
. oprobit Y X1 X2 X3 X4 X5 … , vce(cluster countycode)
. margins , at(X1=(0(7)365))

We get this:
Predictive margins Number of obs = 9,407
Model VCE : Robust

1._predict : Pr(Y==1), predict(pr outcome(1))
2._predict : Pr(Y ==2), predict(pr outcome(2))
3._predict : Pr(Y ==3), predict(pr outcome(3))
4._predict : Pr(Y ==4), predict(pr outcome(4))
5._predict : Pr(Y ==5), predict(pr outcome(5))

------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_predict#_at |
1 1 | . (not estimable)
1 2 | . (not estimable)
1 3 | . (not estimable)
1 4 | . (not estimable)


So, we re-ran the model and tried the mgen approach

. mgen, at(X1=(0(7)365))

Predictions from: margins, at(X1=(0(7)365)) predict(outcome())

Variable Obs Unique Mean Min Max Label
-------------------------------------------------------------------------------
_pr1 0 0 . . . pr(y=1) from margins
_ll1 0 0 . . . 95% lower limit
_ul1 0 0 . . . 95% upper limit
_X1 53 53 182 0 364 TmaxW_30-10
_Cpr1 0 0 . . . pr(y<=1)
_pr2 0 0 . . . pr(y=2) from margins
_ll2 0 0 . . . 95% lower limit
_ul2 0 0 . . . 95% upper limit
_Cpr2 0 0 . . . pr(y<=2)
_pr3 0 0 . . . pr(y=3) from margins
_ll3 0 0 . . . 95% lower limit
_ul3 0 0 . . . 95% upper limit
_Cpr3 0 0 . . . pr(y<=3)
_pr4 0 0 . . . pr(y=4) from margins
_ll4 0 0 . . . 95% lower limit
_ul4 0 0 . . . 95% upper limit
_Cpr4 0 0 . . . pr(y<=4)
_pr5 0 0 . . . pr(y=5) from margins
_ll5 0 0 . . . 95% lower limit
_ul5 0 0 . . . 95% upper limit
_Cpr5 0 0 . . . pr(y<=5)

--------------------------------------------------------------------------------

So we tried:

. margins, at(X1=(0(7)365)) predict(outcome(1)) predict(outcome(2)) predict(outcome(3)) predict(outcome(4)) predict(outcome(5))

------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_predict#_at |
1 1 | . (not estimable)
1 2 | . (not estimable)
1 3 | . (not estimable)
1 4 | . (not estimable)
1 5 | . (not estimable)
1 6 | . (not estimable)
1 7 | . (not estimable)
...


It feels like the problem is in the model, but we are not sure how to identify the issue. Otherwise, are we doing something wrong in our effort to graph the margins?

new version of stdtable package available on SSC

$
0
0
Thanks to Kit Baum an update of the package, stdtable, is now available from SSC. It can be installed by typing in Stata ssc install stdtable. The biggest change is the way the replace option works. stdtable can overwrite the data with the table it creates by specifying the replace option. This can be useful for creating graphs, but the downside is that it overwrites the data. This new version allows the replace(frame_name) option, which will replace the data in the data frame frame_name. The regular replace option still works, and is the only one allowed for Stata versions less than 16 (as data frames were introduced in Stata 16).

stdtable standardizes a cross tabulation such that the marginal distributions (row and column totals) correspond to some pre-specified distribution, a technique that goes back to at least (Yule 1912). The purpose is to display the association that exists in the table nett of the marginal distributions. Consider the example below:


Code:
. use "http://www.maartenbuis.nl/software/mob.dta", clear
(mobility table from the USA collected in 1973)

. tab row col [fw=pop]

       Father's |                    Son's occupation
     occupation | upper non  lower non  upper man  lower man       farm |     Total
----------------+-------------------------------------------------------+----------
upper nonmanual |     1,414        521        302        643         40 |     2,920
lower nonmanual |       724        524        254        703         48 |     2,253
   upper manual |       798        648        856      1,676        108 |     4,086
   lower manual |       756        914        771      3,325        237 |     6,003
           farm |       409        357        441      1,611      1,832 |     4,650
----------------+-------------------------------------------------------+----------
          Total |     4,101      2,964      2,624      7,958      2,265 |    19,912
There are many more people that went from a farm to lower manual than the other way around. However, the number of people in agriculture strongly declined so sons had to leave the farm. Moreover, the number of people in lower manual occupations were on the increase, offering room for those sons that had to leave their farm. We may be interested in knowing if this asymmetry is completely explained by these changes in the marginal distribution, or if there is more to it.


Code:
. stdtable row col [fw=pop], format(%5.0f) cellwidth(9)

----------------------------------------------------------------------------------
Father's        |                         Son's occupation                        
occupation      | upper non  lower non  upper man  lower man       farm      Total
----------------+-----------------------------------------------------------------
upper nonmanual |        42         24         17         13          4        100
lower nonmanual |        27         30         18         18          6        100
   upper manual |        16         20         33         23          8        100
   lower manual |        11         21         22         34         12        100
           farm |         4          6          9         12         69        100
                |
          Total |       100        100        100        100        100        500
----------------------------------------------------------------------------------
These standardized counts can be interpreted as the row and column percentages that would occur if for both fathers and sons each occupation was equally likely. It appears that the apparent asymmetry was almost entirely due to changes in the marginal distributions. Also, it is now much clearer that farming is much more persistent over generations than the other occupations.

Optimal cutoff lroc curve after probit

$
0
0
Does anyone know how to get the optimal cutoff point of lroc curve after a probit estimation?


Twoway line for tabulated results

$
0
0
Hello Everyone!

I am using stata 16 and my data us the demographic health survey women's module. I created a dummy variable domvio = 1 if the respondent has faced any form of domestic violence and = 0 otherwise. I wanted to plot it in a line graph against the respondent's partner's education level (range 1 to 20), basically plot the results from the following command as a twoway line graph.

Code:
tab domvio part_educ_lvl
I get the following output:
highest year of education
domvio 0 1 2 3 4 5 6 7 8 9 10 11 20 Total
0 4 34 93 81 54 160 3 4 0 0 0 0 0 433
1 355 3,196 6,225 6,831 5,887 11,472 133 224 38 8 4 3 3 34,379
Total 359 3,230 6,318 6,912 5,941 11,632 136 228 38 8 4 3 3 34,812
I can successfully get a bar graph for this but it would seem visually better if I had a line graph showing me the percentage of women who reported facing domestic violence by relative's education.

For the bar graph I used the following code

Code:
egen mean = mean(100 * domvio), by(part_educ_lvl)
egen tag = tag(part_educ_lvl)
graph bar (asis) mean if tag, over(part_educ_lvl) blabel(total, format(%2.1f)) yla(0(10)60)
Array
I am just not certain how to translate this into a line graph.


Thanks a lot.
Lori

Forval loops with if-conditions in Panel data

$
0
0
Hello together.

I am still struggling with my current research. I want to run the following code in my panel data set:

Code:
tsset ID year 
forval i = 1/2 if varX == 1 {
forval t = Year if varX == 1 {
noisily synth varA varB, trunit(`i') trperiod
(`t') }
The data look like this:
Id year VarX VarA VarB
1 2002 0 0.1234 ...
1 2003 1 0.1234 ...
1 2003 0 0.1234 ...
2 2002 0 0.1234 ...
2 2003 0 0.1234 ...
2 2004 1 0.1234 ...
The synth-code itself works perfectly by hand. The problem is the second loop and and "if" -condition.

My objective: I want to run the synth for all IDs (
`i')
that have a VarX with 1 and for the respective year
(`t')
.

Thank you.

Konstantin

Doing Diff-in-Diff with lagged dependent using xtabond

$
0
0
Hi,
I'm doing a diff-in-diffs type of model with xtabond, but would be grateful for help establishing if I'm doing it correctly.

In principle, I have app. 52 units, observed over, on average, 50 periods (but highly unbalanced, ranging from 9 to 99).

I previously did a panel fixed effects but would like to do Arellano-Bond with lagged dependent variable (one lag).

I also have one explaining variable that I believe affects only future periods (the explained variable is series episode viewership, and the explaining variable in question is episode rating).

And, finally, I want to include time trends (separate trend for the treatment group and separate for the control group), including a potential change in the trend post-treatment.

So, right now, this is what I have more or less:

Code:
xtabond  Y  POST_TREAT  TREATED_POST_TREAT  ///
TIME  TREATED_TIMETIME_POST_TREAT  TREATED_TIME_POST_TREAT  ///
OTHERCONTROLS, lag(1) vce(robust) pre(RATING, lag(1,.))
The first line includes the typical diff-in-diff variables indicating period after treatment and the same but only for the treated. The "TREATED" variable is not included as it is constant over time.
The second line includes the trend, the trend for the treated group, and then both but only after the treatment.

Then I have some other controls (e.g. for the TV show season finale). I include the rating variable as a predetermined one. I understand that this is the right approach if I expect a shock in the variable to only have an effect on the future values of the dependent variable and not on the preceding ones.

I'd be very grateful for any comments - whether I should include something else as well, or if this is ok.

Thank you and kind regards,
WH

Structural Breaks in time-series

$
0
0
Hi everyone!

I really need your advice!! I have a multivariate time-series model with yearly observations. I have run the engle-granger 2-step ecm procedure and I found co-integration. Now, I want to check for structural breaks in the co-inetgrated equation. Does anyone know how I can do this? The command estat sbsingle does not work for me, only the estat sbcusum gives results. I've also tried the ghansen test, but unfortunately, I use five independent variables and ghansen supports only 4 left-hand side variables. I would like to perform a Chow test, but I cannot find it. Is there any code about that? Does anyone have an idea? Thank you in advance, I really appreciate your help!

Interpretation of Outreg2 table on terrorism event study

$
0
0
Hi everyone!

I am a student and do a thesis on the abnormal return generated by domestic terrorism events in the US, an event study.
For this I use dummy and continuous variables.
I use Stata version 15.1 using xtscc

I did an xtscc regression, since the panel data was cross-sectional correlated. I have ten specified industries I interpret, however I also have to interpret the impact on the entire NYSE.
The following table presents the impact of the events on the entire NYSE.
(1) (2) (3) (4) (5) (6)
VARIABLES US Casualties Motive Mortality Rate Location Dispersion Suicide
Act of terrorism (dummy) 0.00197 0.0537** 0.00496 0.0488** 0.0118 0.00901
(0.0124) (0.0182) (0.0121) (0.0185) (0.0140) (0.0126)
One year lag (numeric continuous) -0.0181* -0.0182* -0.0181* -0.0181* -0.0181* -0.0181*
(0.00910) (0.00910) (0.00910) (0.00910) (0.00910) (0.00910)
Islam inspired motive (dummy) -0.0732**
(0.0320)
Right wing political motive (dummy) -0.0508**
(0.0184)
Other motive (dummy) -0.0336**
(0.0119)
US Casualties (dummy) 0.0315
(0.0320)
Mortality Rate US citizens (numeric continuous) 0.00564*
(0.00261)
Target New York City (dummy) -0.0304
(0.0249)
Target Financial city (dummy) -0.0628
(0.0530)
Other location (dummy) -0.0388**
(0.0125)
Dispersion in days (numeric continuous) -0.000228
(0.000460)
Suicide by perpetrator(s) (dummy) -0.0254
(0.0768)
Constant 0.00374 0.00425 0.00370 0.00429 0.00386 0.00380
(0.00417) (0.00417) (0.00417) (0.00417) (0.00416) (0.00416)
Observations 42,770 42,770 42,770 42,770 42,770 42,770
R-squared 0.000 0.000 0.000 0.000 0.000 0.000
Number of groups 10 10 10 10 10 10
Standard errors in parentheses
*** p<0.01, ** p<0.05, * p<0.1

I am stuck on the interpretation of the table, as I find it difficult to read the effect.

An example of my data is the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(industry date3) double Dispersion float(NewYorkCity Financialcities Terrorism suicide IslamInspired RightWingTerrorism OtherMotive nkillus USCasualties Otherlocation lag_norm)
1   1  0 0 0 0 0 0 0 0 0 0 0          .
1   2  0 0 0 0 0 0 0 0 0 0 0  .14726657
1   3  0 0 0 0 1 1 0 0 0 0 1  -.3925821
1   4  0 0 0 0 0 0 0 0 0 0 0 -1.4826362
1   5  0 0 0 0 0 0 0 0 0 0 0    .349348
1   6  0 0 0 0 0 0 0 0 0 0 0 -.55608904
1   7  0 0 0 0 0 0 0 0 0 0 0 -1.9572344
1   8  0 0 0 0 0 0 0 0 0 0 0  -.9028165
1   9  0 0 0 0 0 0 0 0 0 0 0   .1916338
1  10  0 0 0 0 0 0 0 0 0 0 0   .9699838
1  11  0 0 0 0 0 0 0 0 0 0 0   .9682758
1  12  0 0 0 0 0 0 0 0 0 0 0  .41327965
1  13  0 0 0 0 0 0 0 0 0 0 0 .001258254
1  14  0 0 0 0 0 0 0 0 0 0 0  -5.428175
1  15  0 0 0 0 0 0 0 0 0 0 0  -.0948005
1  16  0 0 0 0 0 0 0 0 0 0 0  .12732422
1  17 21 0 0 1 0 0 0 1 0 0 1  2.2153707
1  18  0 0 0 0 0 0 0 0 0 0 0  -5.388564
1  19  0 0 0 0 0 0 0 0 0 0 0  2.3124878
1  20  0 0 0 0 0 0 0 0 0 0 0 -3.1812844
1  21  0 0 0 0 0 0 0 0 0 0 0   4.726941
1  22  0 0 0 0 0 0 0 0 0 0 0   .9461601
1  23  0 0 0 0 0 0 0 0 0 0 0  -1.822937
1  24  0 0 0 0 0 0 0 0 0 0 0  -.5067613
1  25  0 0 0 0 0 0 0 0 0 0 0   .8031158
1  26  0 0 0 0 0 0 0 0 0 0 0   3.311516
1  27  0 0 0 0 0 0 0 0 0 0 0   .6476688
1  28  0 0 0 0 0 0 0 0 0 0 0   2.111576
1  29  0 0 0 0 0 0 0 0 0 0 0  .15575874
1  30  0 0 0 0 0 0 0 0 0 0 0 -.03409575
1  31  0 0 0 0 0 0 0 0 0 0 0 -1.8898008
1  32  0 0 0 0 0 0 0 0 0 0 0   2.612545
1  33  0 0 0 0 0 0 0 0 0 0 0  -1.880528
1  34  0 0 0 0 0 0 0 0 0 0 0 -.23485056
1  35  0 0 0 0 0 0 0 0 0 0 0 -.24395937
1  36  0 0 0 0 0 0 0 0 0 0 0 -2.0437975
1  37  0 0 0 0 0 0 0 0 0 0 0  2.1375442
1  38  0 0 0 0 0 0 0 0 0 0 0 -1.0830109
1  39  0 0 0 0 0 0 0 0 0 0 0  1.0365268
1  40  0 0 0 0 0 0 0 0 0 0 0  .24014443
1  41  0 0 0 0 0 0 0 0 0 0 0     1.0486
1  42  0 0 0 0 0 0 0 0 0 0 0 -.47032595
1  43  0 0 0 0 0 0 0 0 0 0 0 -.15876883
1  44  0 0 0 0 0 0 0 0 0 0 0   .3237863
1  45  0 0 0 0 0 0 0 0 0 0 0 .024296284
1  46  0 0 0 0 0 0 0 0 0 0 0  -1.103821
1  47  0 0 0 0 0 0 0 0 0 0 0   1.144811
1  48  0 0 0 0 0 0 0 0 0 0 0  -.5415889
1  49  0 0 0 0 0 0 0 0 0 0 0   .3856568
1  50  0 0 0 0 0 0 0 0 0 0 0  -1.426194
1  51  0 0 0 0 0 0 0 0 0 0 0   1.429711
1  52  0 0 0 0 0 0 0 0 0 0 0   .3579682
1  53  0 0 0 0 0 0 0 0 0 0 0 .033926666
1  54  0 0 0 0 0 0 0 0 0 0 0  -2.720959
1  55  0 0 0 0 0 0 0 0 0 0 0  -.2142462
1  56 57 0 0 1 0 0 0 1 0 0 1   .1400603
1  57  0 0 0 0 0 0 0 0 0 0 0   .9721905
1  58  0 0 0 0 0 0 0 0 0 0 0   .3362675
1  59  0 0 0 0 0 0 0 0 0 0 0  -.3609953
1  60  0 0 0 0 0 0 0 0 0 0 0 -2.3436384
1  61  0 0 0 0 0 0 0 0 0 0 0   .6113771
1  62  0 0 0 0 0 0 0 0 0 0 0 -2.7633216
1  63  0 0 0 0 0 0 0 0 0 0 0 -3.8684616
1  64  0 0 0 0 0 0 0 0 0 0 0  -.6188751
1  65  0 0 0 0 0 0 0 0 0 0 0  1.4791256
1  66  0 0 0 0 0 0 0 0 0 0 0  .09460098
1  67  0 0 0 0 0 0 0 0 0 0 0  1.4264836
1  68  0 0 0 0 0 0 0 0 0 0 0    .192537
1  69  0 0 0 0 0 0 0 0 0 0 0 -.10378847
1  70  0 0 0 0 0 0 0 0 0 0 0   .4740425
1  71  0 0 0 0 0 0 0 0 0 0 0   .7206583
1  72  0 0 0 0 0 0 0 0 0 0 0 -.21743584
1  73  0 0 0 0 0 0 0 0 0 0 0 -1.2229074
1  74  0 0 0 0 0 0 0 0 0 0 0  -.3419091
1  75  0 0 0 0 0 0 0 0 0 0 0  2.0386014
1  76  0 0 0 0 0 0 0 0 0 0 0 -.10929382
1  77  0 0 0 0 0 0 0 0 0 0 0    1.64022
1  78  0 0 0 0 0 0 0 0 0 0 0 -1.8230085
1  79  0 0 0 0 0 0 0 0 0 0 0   3.451079
1  80  0 0 0 0 0 0 0 0 0 0 0   .5227447
1  81  0 0 0 0 0 0 0 0 0 0 0   .8057634
1  82  0 0 0 0 0 0 0 0 0 0 0  1.1821617
1  83  0 0 0 0 0 0 0 0 0 0 0  -.7251104
1  84 40 0 0 1 0 0 0 9 0 0 9   .4699563
1  85  0 0 0 0 0 0 0 0 0 0 0  -.8884256
1  86  0 0 0 0 0 0 0 0 0 0 0 -1.2359784
1  87  0 0 0 0 0 0 0 0 0 0 0   .8916743
1  88  0 0 0 0 0 0 0 0 0 0 0  -1.816106
1  89  0 0 0 0 0 0 0 0 0 0 0 -1.6005353
1  90  0 0 0 0 0 0 0 0 0 0 0  -.6391434
1  91  0 0 0 0 0 0 0 0 0 0 0   .9389873
1  92  0 0 0 0 0 0 0 0 0 0 0  1.3203605
1  93  0 0 0 0 0 0 0 0 0 0 0  1.2037504
1  94  0 0 0 0 0 0 0 0 0 0 0   .9205027
1  95  0 0 0 0 0 0 0 0 0 0 0  1.2869184
1  96  0 0 0 0 0 0 0 0 0 0 0 -.51946497
1  97  0 0 0 0 0 0 0 0 0 0 0   .3548341
1  98  0 0 0 0 0 0 0 0 0 0 0 -.16927294
1  99  0 0 0 0 0 0 0 0 0 0 0   .3343731
1 100  0 0 0 0 0 0 0 0 0 0 0   -1.82412
end

These are the commands I used to get to the table.

*Outreg2 for all observations
Code:
xtscc norm_return Terrorism lag_norm USCasualties
outreg2 using AllObservations.doc, replace ctitle(US Casualties) label
xtscc norm_return Terrorism lag_norm IslamInspired RightWingTerrorism OtherMotive
outreg2 using AllObservations.doc, append ctitle(Motive) label
xtscc norm_return Terrorism lag_norm nkillus
outreg2 using AllObservations.doc, append ctitle(Mortality Rate) label
xtscc norm_return Terrorism lag_norm NewYorkCity Financialcities Otherlocation
outreg2 using AllObservations.doc, append ctitle(Location) label
xtscc norm_return Terrorism lag_norm Dispersion
outreg2 using AllObservations.doc, append ctitle(Dispersion) label
xtscc norm_return Terrorism lag_norm suicide
outreg2 using AllObservations.doc, append ctitle(Suicide) label
Can anybody help me?

Thanks in advance!

Y-Axis label

$
0
0
Hello guys, I'll try to keep this as short as possible, thanks for any advice in advance.

I'm currently trying to combine several graphs into one and want all of these single graphs to have the same Y-scale/label (say from +2 to -20).

Code:
tw (rarea up95bbci lo95bbci h, bcolor(gs12) clw(medthin medthin)), yscale(range(-20 0)),(rarea up68bbci lo68bbci h, bcolor(gs10) clw(medthin medthin))(scatter bbci h,c(l l l) clp(l - .) ms(o i i) clc(blue red green) mc(blue red green) clw(medthick))if h<=`hor' , title("Deutschland BCI", size(medsmall)) legend(off) xtitle("months") scale(0.9)
Here is the code I use as an example.

The resulting graph looks like this

Array
Preferably I would like the Y-axis to go from +2 to -10 in steps of 1, but despite trying around for some time using different commands I have not gotten it to work.

I would be thankful for any help.

Dropped Observations after Importing Excel Sheet as a CSV File

$
0
0
I have an excel sheet I downloaded as a csv file. The number of observations is over 150,000. I imported the csv file, and noticed some things were off. After checking the number of observations with the original file, the number of observations in the imported file was at around 141,000. I was wondering if anyone knows why a fair amount of observations were dropped after importing the file. (I find this so strange. Also, as a small FYI, I am running on Stata 14).

This does not happen when I import the data as an excel file (.xlsx). However, when I import the excel file as a .xlsx, it runs slower and my variables turn into string variables. I have tried to destring them with destring, replace but it does not destring and reads the variables as non-numeric. I am a little bit at a loss. Thanks for any help and/or leads!

Help with longitudinal mixed model

$
0
0
Hi all

New to this forum. I'm working on a longitudinal mixed model and wanted to ensure the model is specified correctly. Below are the model specifications:

Dependent variable: Severity-of-illness score
Independent variables: Study intervention (treatment vs. placebo) ; Time (0,24, 72 hours) ; study site (14 sites as categorical variables) ; time*intervention interaction term
Outcome of interest: Effect of the intervention on severity-of-illness score over time (i.e. the time*intervention interaction term)

The model is currently specified as:
xtset subject_ID time
mixed score time##intervention i.site||subject_ID, var residuals (ar, t(time))
contrast intervention##time

This then gives a chi2 and p-value for the interaction term

Appreciate any thoughts!

Sam


Viewing all 65580 articles
Browse latest View live


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