Error message in Stata: Cannot compute an improvement -- discontinuous region encountered (for panel ordered logit/probit model) - stata

I have panel data for OECD countries between the years 2010 and 2021. I use stata 14.
I categorize GINI into 4 groups as follows
This is named as d_gini, which is my dependent variable. And I apply the panel data ordered probit model. I regress it on World Pandemic Discussion Index (WPDI) as follows:
But, regardless of probit or logit model, I encounter with this error. How can I fix it?
Thank you.
Note: When I try this panel ordered logit regression with different explanatory variable, for example I use log_GDP in stead of WPDI, this regression works. I don't see any error. However, I need to use this explanatory variable WPDI. How can I fix?

Related

Do you still need to include "site" as a random effect when modeling matched data set?

I am working on a multicenter propensity matched cohort study. The primary outcome is binary while the secondary outcome is continuous. First I performed multiple imputation to address the missing data. I initially planned exact matching on the sites in addition to matching on other variables of interests but got very poor matches. Then I used variables that described the characteristics of the sites, which I compared with the site variable using c statistic and they had similar values. With this new variables and the other variables of interest I got a much better match. I then performed within imputation conditional logistic regression for the binary variable and pulled the results. For the secondary outcome I used negative binomial regression including the match ID in the class statement and as a repeated statement. Do I need to include 'site' as a random statement in the model? I don't know if this is possible in conditional logistic regression. What would be the best way to model this data after matching? For this study I used SAS for analysis.

Proc reg using by variable (month): How do you take average of all coefficients across all months?

How do you take an average of the coefficients across all months?
Please refer to this question earlier
How do I perform regression by month on the same SAS data set?
The comments in the linked question provide the code to get the estimates in a data set. Then you would run a PROC MEANS on the saved data set to get the averages. But you could also run the model without which a variable to get the monthly estimates alone. In general, it isn't common to average parameter estimates this way, except in a bootstrapping process.

How to obtain individual estimates (slopes/intercepts) in proc mixed (SAS)

I'm interested in seeing how sedentary behaviors change throughout time (Time 1, 2, 3) and see in a second step how it relates to mental health.
Thus, I would like to obtain an estimate (slope/intercept) for each subject to allow me to do the 2nd step. I can't find online how to do it (not sure what to search for).
Here's my code so far, which gives me 2 estimates (boys and girls); I would rather have an estimate for every participant.
ods output LSMeans=Means1;
proc mixed data=sb.LFcomplete method=ml covtest;
class SexeF time;
model CompDay = Time SexeF Time*SexeF;
repeated time;
lsmeans time*sexeF;
run;
Thank you in advance!
Please check this website for a similar example:
https://www.stat.ncsu.edu/people/davidian/courses/st732/examples/ex10_1.sas
The professor was using HLM for longitudinal data analysis. He used gender like your SexeF, age like your Time, and child as ID. The tricky part is when he was organizing the random effect file, he sorted ID and created Gender (Group or your SexeF) for subsequent merging with the fixed effects file. If your current ID variable is not aligned with your SexeF, you may sort your SexeF and create a new ID variable in SPSS before you import your data in SPSS.

Why do I get different regression outputs in SAS and in Stata when using Prais-Winsten estimation?

I have a time series dataset with serious serial correlation problem, so I adopted Prais-Winsten estimator with iterated estimates to fix that. I did the regressions in Stata with the following command:
prais depvar indepvar indepvar2, vce(robust) rhotype(regress)
My colleague wanted to reproduce my results in SAS, so she used the following:
proc autoreg data=DATA;
model depvar = indepvar indepvar2/nlag=1 iter itprint method=YW;
run;
For the different specifications we ran, some of them roughly match, while others do not. Also I noticed that for each regression specification, Stata has many more iterations than SAS. I wonder if there is something wrong with my (or my colleague's) code.
Update
Inspired by Joe's comment, I modified my SAS code.
/*Iterated Estimation*/
proc autoreg data=DATA;
model depvar = indepvar indepvar2/nlag=1 itprint method=ITYW;
run;
/*Twostep Estimation*/
proc autoreg data=DATA;
model depvar = indepvar indepvar2/nlag=1 itprint method=YW;
run;
I have a few suggestions. Note that I'm not a real statistician and am not familiar with the specific estimators here, so this is just a quick read of the docs.
First off, the most likely issue is that it looks like SAS uses the OLS variance estimation method. That is, in your Stata code, you have vce(robust), which is in contrast to what I read SAS as using, the equivalent of vce(ols). See this page in the docs which explains how SAS does the Y-W method of autoregression, compared to this doc page that explains how Stata does it.
Second, you probably should not specify method=YW. SAS distinguishes between the simple Y-W estimation ("two-step" method) and iterated Y-W estimation. method=ITYW is what you want. You specify iter, so it may well be that you're getting this anyway as SAS tends to be smart about those sorts of things, but it's good to verify.
I would suggest actually turning the iterations off to begin with - have both do the two-step method (Stata option twostep, SAS by removing the iter request and specifying method=YW or no method specification). See how well they match there. Once you can get those to match, then move on to iterated; it's possible SAS has a different cutoff than Stata and may well not iterate past that.
I'd also suggest trying this with only one independent and dependent variable pair first, as it's possible the two programs handle things differently when you add in a second independent variable. Always start simple and then add complexity.

Automated regression procedure in Stata

I'm going to study the relationship between the illiquidity and returns in stock markets, using the Amihud model proposed in the paper "Illiquidity and stock returns: cross-section and time-series effects" (2002). I would like to know if it is possible to automate the regression analysis. I've have more than 2000 stocks in the sample and I'd like to avoid to run each regression one-by-one, speeding the process up.
Do you know if it is possible automate this process in Stata? or if is it possible to do that using some other statistical software (R, SAS, Matlab, Gretl,...) ? If it is, how could I do that?
You should look at foreach and forval as ways of looping.
forval i = 1/3 {
regress Ystock`i' Xstock`i'
}
would be an example if and only if there are variables with names like those you indicated. If you have other names, or a different data structure, a loop would still be possible.