4,664 questions
0
votes
0
answers
40
views
Why does `estat phtest` return missing values (.) when testing proportional hazards assumption in Cox PH regression using Stata?
I am fitting a Cox proportional hazards model in Stata and checking the proportional hazards (PH) assumption using estat phtest.
Here is how I set up my survival data:
stset time, failure(event)
...
1
vote
2
answers
51
views
Are there reserved words or locals in Stata program syntax starting with "no"?
I wrote a program and gave its syntax the optional option nosort. It's behaving strangely and my hunch is that it might be a reserved word of some kind. Here is some example code. Two programs that do ...
0
votes
0
answers
32
views
How to create a table of survey-weighted means by cohort using svy: mean
I am working with survey data and want to compute the survey-weighted mean of age at sexual initiation by year of birth (yob) cohort, along with standard errors and 95% confidence intervals.
I've ...
0
votes
0
answers
49
views
Is it possible to use FallBack fonts in stata/MP?
As the title, I need the fallback settings of the fonts in Stata 17's do-editor. Is that possible?
I found that there is only one font could be set in the right-click preferences:
I want fontA for ...
0
votes
0
answers
131
views
Stata: storing "Post_avg" regression coefficient from csdid
I'd like to be able to store and save the "Post_avg" regression output from Stata's csdid command so that I can automate the production of regression tables. When I try
**egen gvar = csgvar(...
2
votes
1
answer
108
views
How to force graph to stop displaying after a certain x-axis value
In Stata, how can I force the graph to stop displaying after a certain point on the x-axis?
For instance, say that I have:
sysuse auto2, clear
gen mid = (price + weight)/2
gen n = _n
twoway ///
...
0
votes
0
answers
24
views
Viewsource in Stata for "combined" commands
Code like viewsource ivregress.ado allows us to see the implementation of the command in Stata.
How can I access the implementation of something like ivregress postestimation/estat endog?
-2
votes
1
answer
100
views
Unable to collapse the data in loop and create variables [closed]
I am trying to create a loop in Stata so that I can add multiple variables for creating mean_var and median_var. However, this data isn't creating any variables; the collapsed_file is the same as my ...
0
votes
0
answers
61
views
Stata nonlinear least squares with many coefficients: shortening command
I want to estimate (the Greek characters are coefficients to be estimated):
where D_{it}^d are dummy variables (=0 or 1), and {\theta_i}_i,delta are to be estimated. i can be large, so there are a ...
0
votes
1
answer
67
views
How can I solve this Stata 16 table problem?
I created this code that works correctly in Stata 17, but when I try to replicate and run it in Stata 16, it produces errors. The main issue is that it only generates the table considering the first ...
0
votes
0
answers
28
views
What do you do if the numerical values of the spatial Durbin model LM test (spatdiag) are too large to display accurate data?
Please help me, I am using Stata for LM test and the code is as follows:
spatdiag,weights(x1)
however, the Lagrange multiplier and Robust Lagrange multiplier are displayed in scientific notation due ...
-1
votes
1
answer
91
views
How to use the Stata equivalent of a foreach loop in R with mutate() [duplicate]
I have 4 different variables in my raw data (all starting with the prefix raw_), followed by combinations of hours/money and school/social. In my real data, I have many more options for each value of ...
0
votes
1
answer
54
views
Variable display format
Stata receives my commands for the justification of a string variable named make on the right (format make %18s) and left (format make %-18s). This reception results from the ‘properties’ table. ...
0
votes
0
answers
99
views
On VS Code, how can I create sections/bookmark specific lines in a Stata do-file?
I am writing a dofile (Stata script) on VS Code, and since it's pretty long, I would like to divide it into different sections so that I can easily navigate the script and quickly get to the lines I ...
0
votes
1
answer
53
views
How to split a variable?
I have one string variable which has 4 characters: the first two are the hours and the second two are the minutes. How can I split that variable into two variables, one for the hours and the other for ...
0
votes
1
answer
117
views
How to Create Section Headers in Stata Output
I am new to using Stata and I am currently trying to learn how to better organize the output of my Stata scripts for easier reading and presentation. I've seen some outputs that have visually distinct ...
0
votes
1
answer
91
views
How can I plot the results of an IV interaction from ivreg2?
I've got this IV specification that I would like to plot to have the marginal effect of x1 on y as a function of x2:
ivreg2 y= (x1 x1#x2 = z1 z1#x2), endog(x1 x1#x2)
with x1 and x2 continuous and z1 ...
0
votes
1
answer
57
views
Ado file return matrix
I'm trying to write an ado file that return my matrix
prog drop EM
program define EM, eclass
matrix P0 = (.9, 0.09,0.01 \ 0.1, 0.8, 0.1 \ 0.05, 0.15, 0.8)
return P0
end
EM
The error I got is invalid ...
0
votes
1
answer
149
views
Stata putexcel: add numbers with stars to a table
I want to create a table for Excel, based on numbers from Stata. A cell might have a number and stars (indicating statistical significance), such as "0.15***".
Minimal example attempts in ...
1
vote
1
answer
227
views
Does anyone know how to make confidence intervals appear when using the "estat trendplots" command in Stata (after running "xtdidregress")
The title says it all.
After running a diff-in-diff in Stata with "xtdidregress", I am then creating a graph testing the parallel trends assumption using the command "estat trendplots&...
1
vote
0
answers
82
views
Stata ODBC - Why does declaring a temporary function in my query yield an error?
I'm trying to load data into Stata from a SQL database hosted in Databricks, via the odbc load command. For part of the query I need to declare and run a small Python function (Databricks SQL, or at ...
0
votes
0
answers
996
views
did_multiplegt_dyn with controlvariables
I run a staggered DiD regression with the Stata command did_multiplegt_dyn by De Chaisemartin, C., & d'Haultfoeuille, X. (2024). Without control vars the command runs
# Comand without controls
...
0
votes
1
answer
32
views
Lagged range in if statement
I have successfully used lagged values in the "IF" section of a replace. How do I specify a range instead of each individual lagged variables. Iteration is not an option. I have ~...
1
vote
1
answer
239
views
Replicating logistic regression results from Stata in R
I'm facing an issue with replicating the results of a basic logistic regression model in R. The model was originally run in Stata.
The issue is that all of my odds ratios (and their underlying ...
1
vote
1
answer
117
views
Reshaping/transposing data in Stata
I have a table with the first column case IDs and the following columns matched control IDs. Some control IDs will be paired to more than one case ID. There's an index date which corresponds to all ...