stata

How to determine (complex) panel pattern?

匆匆过客 提交于 2019-12-13 02:22:04
问题 My question is closely related to existing discussions on Statalist like this one. I want to raise a new question because I want to look at more complex patterns of panels beyond numbers of consecutive spells. Say, given a panel of firms, I want to check how many years that firm owns no real estate property land == 0 before it buys some land > 0 . Or, even more sophisticatedly, how many years the firm's property is below some level land < 0.05 * land[s] where s refers to the year a firm

Fixed effects regression with state specific trends

房东的猫 提交于 2019-12-13 02:02:44
问题 I'm working with panel data and I want to estimate a fixed effects regression with state specific trends. In Stata, I could accomplish this by the following, xi i.state i.year i.state*time reg y x _I* The above will create state dummies, year dummies, and 50 (state x time) dummies where time numerically identifies the trend (i.e. 1, 2, 3...) In R, I can run a fixed effects model with plm or lm, for example, plm(y ~ x, index = c("state", "year"), effect = "twoways", data = df) lm(y ~ x +

How to get Stata to produce a dynamic forecast when using lagged outcome as a regressor?

落花浮王杯 提交于 2019-12-13 00:43:08
问题 I am currently dealing witha very small data set (20 observations, I know it's terrible). But I need to somehow forecast out the values. When I simply regress time on the dependent variable I am able to get a prediction, but when I add lagged or differenced variables it does not predict more than one year into the future. Is this due to having too few observations? Here is my code for context. The two lines have have commented out result in a better fitting prediction for present data, but

Insert leading zero in a variable

狂风中的少年 提交于 2019-12-13 00:34:24
问题 I have the following problem: I would like to insert a leading zero in the values of a variable holding different customer identification numbers. I have already tried to use the generate command to add the zero, but this did not work. How can i do that in Stata? My variable looks as follows: 567 523 598 679 回答1: You do not specify if your variable is of string or numeric type. If it is the former, you simply need to insert the zero as follows: clear input str3 customer_id "567" "523" "598"

How to overlay multiple plots on the same graph in Stata?

北城余情 提交于 2019-12-12 19:17:42
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 7 years ago . I am using the following code for drawing a plot on a graph in Stata. I want to draw multiple plots on the same graph. Is that possible? Can anyone kindly tell me what to do? What I want to do is to have multiple plots of the following types in the same graph. Further clarification: There will be multiple means and CIs for each value of X, i.e. one mean and CI for each

How to execute multiple-line selection in do-file editor of Stata?

ⅰ亾dé卋堺 提交于 2019-12-12 15:31:58
问题 Does anyone know how to use the "execute selection" function in the do-file editor of Stata for code that spans multiple lines? Currently I can't find a way to do this without using the #delimit ; system which requires repeating "delimit ;" at the beginning of every block I want to run. Any suggestions appreciated! 回答1: I believe that you might be understanding the #delimit ; command wrongly: this is useful when you are coding a do-file to execute it in its entirety afterwards. I also assume

Remove middle character from variable names

廉价感情. 提交于 2019-12-12 12:17:34
问题 I have variable names ending with an underscore ( _ ), followed by a year code: clear set obs 1 foreach var in age_58 age_64 age_75 age_184 age_93 age99 { generate `var' = rnormal() } list +----------------------------------------------------------------------+ | age_58 age_64 age_75 age_184 age_93 age99 | |----------------------------------------------------------------------| 1. | .1162236 -.8781271 1.199268 -1.475732 .9077238 -.0858719 | +---------------------------------------------------

Extensive documentation on how to write a lexer for Pygments? [closed]

怎甘沉沦 提交于 2019-12-12 07:36:04
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I have a dictionary of Stata keywords and reasonable knowledge of Stata syntax. I would like to devote a few hours to turn it into a Stata lexer for Pygments. However, I cannot find enough documentation about the syntax of lexers and find myself unable to start coding the lexer. Could someone point out a good

How to transform long to wide data in Stata?

点点圈 提交于 2019-12-12 06:20:01
问题 I have this data: id test test_date value 1 A 02/06/2014 12:26 11 1 B 02/06/2014 12:26 23 1 C 02/06/2014 13:17 43 1 D 02/06/2014 13:17 65 1 E 02/06/2014 13:17 34 1 F 02/06/2014 13:17 64 1 A 05/06/2014 15:14 234 1 B 05/06/2014 15:14 646 1 C 05/06/2014 16:50 44 1 E 05/06/2014 16:50 55 2 E 05/06/2014 16:50 443 2 F 05/06/2014 16:50 22 2 G 05/06/2014 16:59 445 2 B 05/06/2014 20:03 66 2 C 05/06/2014 20:03 77 2 D 05/06/2014 20:03 88 2 E 05/06/2014 20:03 44 2 F 05/06/2014 20:19 33 2 G 05/06/2014 20

Stata — output results of ttest

丶灬走出姿态 提交于 2019-12-12 06:12:38
问题 I have data by group_id (1,2,3 and so on). I have to run a t test by group_id . Below I am providing the code I think I will be using for each group_id . How can I modify it so that I can loop over group_ids and get an output with all the t tests combined? Will appreciate any help. Thanks. ttest return, by(test_indicator) unequal 回答1: The by prefix can repeat the t-test for each group_id , but it is hard to combine with other codes. Here's a quick example of using levelsof and foreach to loop