using the _rmcoll command), but the following worked well for me. While it is easy to check whether variables or scalars exist (using capture confirm variable VARNAME or capture confirm scalar SCALARNAME), it seems more difficult to do for large number of estimates after a regression, especially if some of the dummies are omitted. If you are now interested to store all estimates of all dummies generated by “ i.GROUPVAR“, we need to separate these variable names stored in the loop (starting with _IGROUPVAR_) from all other variable names stored in the loop. Stata reports i.GROUPVAR _IGROUPVAR_111-999 (naturally coded _IGROUPVAR_111 omitted) Occasionally, it happens that some of the coefficients are not estimated due to multicollinearity (be sure to figure out why!), i.e. Where GROUPVAR is the original variable name for which the dummies where created in the regression (using xi:). While this is usually straightforward by writing xi: reg OUTCOME i.GROUPVAR i.OTHERVAR, nocons noomit In this example, we are interested in storing the estimates of the GROUPVAR dummies, but not the dummies of OTHERVAR. fixed effects), you might want to store coefficients as estimates. if you want to save coefficient estimates from a regression with many dummies (e.g. This gives you the range for the dummy variables and the range for the year variables.Īs to your question on using x vs year, I am only hypothesizing, but I think that when you use x it is continuous since Stata isn't looking at your variables, but instead just at the x axis whereas your year variable is discrete (a bunch of integers) so it looks more like a step function.In some applications, e.g. Now, the yr* are your dummy variables and the * is a wildcard calling all variables named like yr Regress gnp year year2 yr* if inrange(year,1967,1990) in the specified range, so we're going to fill those in the dummy varibales generated have null values for years not Tab year if inrange(year,1970,1975), gen(yr) // generate dummy variables Gen year2=year^2 // get the square of the yearly variable Gen year = year(dofq(date)) // get yearly variable One thing to note, I am using a dataset that comes preloaded with Stata and this is usually a nice way to make a MVCE like Nick was saying in your other post. I am not sure why Pearly is giving you such a hard time, I think this may be what you're looking for, but let me know if it is something different: Why does it bring different results then if x should be the same thing as year in this case? The way I understood it, _b, _b and _b call previously calculated coefficients for the corresponding independent variables and then multiplies it with them. Twoway function _b +_b*year + _b*year^2, range(1 70) If I then want to plot the estimated function without the dummies, why do these two bring different things? twoway function _b +_b*x + _b*x^2, range(1 70) I can't make the dummies manually, there will be more than 15 of them in the end). Regress y year year2 i.year if inrange(year,1,70) If I didn't have the restriction for dummies, I believe the commands would be: gen year2=year^2 I'm trying to create a regression that would include a polynomial (let's say 2nd order) of year on a certain interval of year (say 1 to 70) and a number of dummies for certain values of year (say for every year between 45 and 60).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |