Hot answers tagged

13

In my university the choice of program is considered generally irrelevant. We focus on results, and it is up to each student to determine which program is best suited for the task and user preference. You will find that using one language translates very well to another. With resources like stackoverflow, I would not be too concerned about which. I would ...


8

You can use code like the following (making use of the as_latex function) to output a regression result to a tex file but it doesn't stack them neatly in tabular form the way that outreg2 does: import pandas as pd import statsmodels.formula.api as smf x = [1, 3, 5, 6, 8, 3, 4, 5, 1, 3, 5, 6, 8, 3, 4, 5, 0, 1, 0, 1, 1, 4, 5, 7] y = [0, 1, 0, 1, 1, 4, 5, 7,0, ...


7

The main economic journals are slowly starting to require authors to make their data and the code of their analysis available as part of the online appendix. When this is the case, it is easy to figure out which software was used. One example are recent publications in the American Economic Review. For instance, Calsamiglia, Caterina, Guillaume Haeringer, ...


6

Basically it's better to use the software your PI uses! First (s)he will be able to correct your code. Second, if you're a TA for a class using one software, it's better to handle it... To find the faculty using R, either have a look at the papers/books published by one department. Or look at the R-packages published in your field and find the authors. I ...


6

If you are only looking for "A department where at least few researchers use R? ", I believe you should be able to find plenty. In my department (Vanderbilt University), I can count at least 3 grad students using R instead of Stata (oh and I guess with myself it makes 4 ;)). If you are looking for more heavily R-oriented econ department, you might ...


5

See RePEc's software top. You'll find much Stata, a bit Matlab, and nothing else. From long personal observations, economists' preferences are ranked like this: Stata (none) Matlab Python, R SAS, Gauss Java, C#, C, Julia are used when performance is important (heavy simulations, combinatorics, etc.). In a specific paper, software is easy to identify ...


5

Use -areg- in Stata, and the standard errors will come out as in the textbook. Specifically, the command areg lpassen lfare ldist ldistsq y98 y99 y00, absorb(id) vce(robust) will produce the desired result. -xtreg- with fixed effects and the -vce(robust)- option will automatically give standard errors clustered at the id level, whereas -areg- with -vce(...


4

I'm still not sure if I'm doing something wrong. However, it is useful to note that I get the same results in R. library(foreign) library(plm) library(lmtest) df <- read.dta("airfare.dta") fe.out <- plm(lpassen ~ lfare + ldist + ldistsq + y98 + y99 + y00, data=df, index = c("id", "year"), method = "within", effect = "individual") ...


4

There is now a Python version of the well known stargazer R package, which does exactly this. See also this related question: https://stackoverflow.com/q/35051673/2858145


3

FE logit requires the idiosyncratic errors to be IID across $i$ and $t$, quite a strong assumption. Also the regressors should be strictly exogenous, but it's the same for linear FE models. In your application, the fact that FE logit wouldn't converge will make a good argument against FE logit, and will satisfy some referees but not all. An important ...


3

If you check Stata's help file on regress you should understand how to do it. Particularly pp. 16-7 have specific examples of how to apply weights. I will edit in order to be more detailed. gen lnyl1y=ln(y)-l1.ln(y) xi: reg lnyl1y i.country [w=y] Notice that if the weighted regression is done by dividing all values for observation $i$ by $\sqrt{w_i}$, ...


3

To understand the issue let's review what is the so call robust variance-covariance matrix estimates (VCE) and the implied "robust" standard errors. The robustness is meant to allow for violations of homoscedasticity in the cross-sectional dimension or heteroscedasticity. There are various heteroscedastic robust VCE which are known as the Sandwich estimators ...


2

Your errors aren't the same anymore. For example, instead of writing $Y = \beta_1 + \beta_2 X + U$, you're actually writing $Y = \alpha_1 + \alpha_2 X + \alpha_3 X^2 + V$. There is no expectation that they should be the same. In other areas, the trouble is that the error term is likely correlated with your regressors. Fear not: running wages on ...


2

It is important to recognize that there are path dependencies to removing different variables from your model. This is due to the fact that variables can be highly correlated (positively or negatively) with one another so that by removing an insignificant variable then other variables can become statistically significant or insignificant. There are very ...


2

You should do none of the above. This is an invalid decision-making process. In the best of all possible worlds, create a series of do loops and go through the set of all possible combinations of variables. Calculate the AIC or the BIC. If you know nothing about either, just pick one as they usually give the same result. The model with the lowest AIC or ...


2

You have firm fixed effects. Presumably, every firm is in the same country throughout your observation period. Moreover, no country ever changes its development status (I assume). Hence, for a given firm, there is no variation in the development status. Therefore, you can't identify an effect.


2

You can use the stargazer package (install with pip install stargazer). From https://github.com/mwburke/stargazer/blob/master/examples.ipynb: import pandas as pd from sklearn import datasets import statsmodels.api as sm from stargazer.stargazer import Stargazer from IPython.core.display import HTML diabetes = datasets.load_diabetes() df = pd.DataFrame(...


2

Have you seen http://faculty.econ.ucdavis.edu/faculty/dlmiller/statafiles/ ? I see some entries there such as Multi-way clustering with OLS and Code for “Robust inference with Multi-way Clustering”. EDIT: At least we can calculate the two-way clustered covariance matrix (note the nonest option), I think, though I can't verify it for now. See the following. ...


2

In panel regressions you have multiple dimensions and that is why also you have 3 different $R^2$. The within $R^2$ tells you how much variation within your panel variables is on average explained by your model. The between $R^2$, tells you how much variation between your panel variables is explained by the model, and overall $R^2$ gives you the combination ...


2

I use all three programs. Python can do everything that R can do and R can do everything that Python does, but I must say R is superior to Python when it comes to the packages. For that reason for most econometric analysis I usually default to R. I find also producing nice standard statistics graphics with R easier (but for maps I prefer Python). However, ...


2

I would advise you to think deeper about your research question first, as this will guide the decision to use country fixed effects. If you would like to exploit cross country variation, for example by studying how the same industry functions differently across countries, then do not use country dummies because it will absorb the variation you want. If you ...


2

In this lecture it is stated at chapter 2.3 that "The Markov switching model and its variants discussed in the preceding sections are only suitable for stationary data". Perhaps you'd like to read into that more thoroughly. Possible solution: Since differentiation is allowed, you should also be able to produce an Error-Correcting Model -and its ...


1

Do the last one, the first one is just the same thing but you will not be using the in-built adf function. The second one does it better and you have a choice of including lagged differences to control for possible autocorrelation. If your data is monthly, give it a lag order of 12.


1

You can use mark. For example, if the treatment was done in the year 2000, and your time variable is called time, the syntax is mark treatment if time >= 2000 & time <. where treatment is the dummy that is generated.


1

Staiger and Stock (1997) formalized the definition of “weak instruments” and most researchers seem to have concluded (incorrectly) from that work (or hearsay) that if the F-statistic on the excluded instruments in the first stage is greater than 10, one need worry no further about weak instruments.Stock and Yogo (2005) go into more detail and ...


1

Note that the fixed effects estimates use only within-firms differences, essentially discarding any information about differences between firms. If predictor variables vary greatly across firms but have little variation over time for each firm, then fixed effects estimates will be imprecise and have large standard errors. So, if there is not enough variation ...


1

You are saying: $y$ is regressed on $x_1$ and $x_2$, say, and you think it would be better to use cluster errors since you expect $y$ is correlated with abilities for each person. First, $y$ is naturally correlated with the error term $u$ (if you mean the error term by "abilities") because $u$ is a part of $y$. You have no problems with that; $y$ is always ...


1

Pooled regression on a panel-data sample, indeed, does not take the time dimension into account. This is why it is called "pooled": we ignore the fact that for each cross-section we have a time series, and we treat the whole panel-data sample as though it were a cross-sectional one, as if, say, $x_{it}$ and $x_{i,t+1}$ are diffrenet cross sections.


1

mean command with pweight gives you mean and sd estimates, which in turn gives you estimate of the coefficient of variation. pctile also takes pweight. It will generate percentiles. kdensity only gives point estimates, not confidence intervals of the density estimates, so I think using fweight instead of pweight is fine. But I'm not certain about this. ...


1

Is this what you want (in Stata)? clear all * Generate Data (n=5, T=20) set obs 100 gen id = floor((_n-1)/20)+1 by id, sort: gen year = 1990+_n gen x = rnormal() xtset id year * Convert gen t5 = floor((year-1991)/5)+1 gen idt5 = id*10+t5 /* 10 can be 100, 1000, etc., depending on T */ by idt5, sort: egen xbar5 = mean(x) *drop t5 idt5 /* drop if ...


Only top voted, non community-wiki answers of a minimum length are eligible