Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    I've looked more into quadratic/U-shaped relationships, particularly searching for references. Before I proceed further in this thread, though, I think we need to clarify how this all got started. As some of the references I have found point out, and as is the motivation for the turning-point location approach that I have been recommending, quadratic is not synonymous with U-shaped, and often quadratic is just (mis)used as a proxy for any type of U-shaped, or even any type of curvilinear relationship. So maybe we need to back up and figure out just what we're getting at here. What motivated you to include the quadratic terms in the regression in the first place? You've already said that theory is silent on the matter. Did you have a hunch that previous modeling in this area that was just linear was missing something? Were you specifically interested in searching for a quadratic model, or were you interested more generally in non-linearity? If the latter, did you have anything specific in mind? I think we should answer these questions so we can pursue an approach that is tailored to the question we are actually facing.

    So does this mean that they may be several models in my work that would seem to be the quadratic model but are not? I will try to calculate all the quadratic models that I have to see their turning points and make sure of where their values fall.
    Yes, there could be models that appear to be quadratic but are in fact some other form of curvilinearity. The turning point method is what I have always relied on to make this distinction, but with the reading I have done since yesterday, there may be better alternatives. But, as in my previous paragraph, let's first get clear exactly what the question is before we select a way to answer it.

    Please, who has run such analysis and how do the commands look like so that I can try them? Please, if there is an alternative means of analyzing my data, I will be open to attempting them.
    The approach with two linear regressions on opposite sides of the data was pioneered b Simonsohn, and I can provide you a reference to it. But until we are sure that is what we need, I'd rather we hold off on that. In any case, if we need it, his reference has a link to code for this in R. I have not found any existing Stata code for it. The approach is conceptually fairly simple, and I don't doubt I could code it in Stata myself for particular models, although it would be difficult to write a fully general program that could be applied to any regression at all.

    Comment


    • #17
      Thank you for your reply.

      You asked: What motivated you to include the quadratic terms in the regression in the first place? You've already said that theory is silent on the matter. Did you have a hunch that previous modeling in this area that was just linear was missing something? Were you specifically interested in searching for a quadratic model, or were you interested more generally in non-linearity?

      Like I said before, theory is silent on the issue, particularly the relationship between gender and the country-level variables I am looking at. So, regarding your question, I was simply interested in the possibility of non-linearity, generally. Like I have implied before, I did not have any hunch guiding how I look at the models. I have not even created the margin plots for many of the models. I am simply trying to use the theory I have to guide the research I am doing so far, and as I mentioned before, the theory has not said much. Thus, my plan was to present what I have found and later decide how my findings relate to the theories I have read.

      Comment


      • #18
        All right. Well, whatever else we can criticize about quadratics as proxies for U-shaped relationships, we know that if the model is actually linear, there is little probability that a quadratic regression will suggest otherwise. So we can take it in steps. First let's decide whether we are dealing with a U-shaped non-linearity or something more like, say, a logarithmic relationship (or square root, or lots of other possibilities). I think Simonsohn's approach, which you can read about at https://journals.sagepub.com/doi/ful...15245918805755 will be helpful. It's a bit complicated to implement, but I can help you with that if you want to go down that path and don't want to do it yourself.

        But before you do that, I suggest you take a step back and explore the relationships graphically. For example, you can do -loess- plots of your dependent variable vs these independent variables. Given your specific interest in the gender interaction, you probably should do those plots separately for men and women. (Caution: with your large sample size, -loess- will be glacially slow. I recommend pulling a random sample of, say, 1,000 observations and use that for the graphical exploration.) These will give us some intuition about what we are likely dealing with before we plunge into the details.

        Comment


        • #19
          Thank you for your reply. I have taken time to think about these issues.

          To be honest, I did not understand Simonsohn's article. However, I ran the Lowess graphs you suggested (with a sample of 10000) and these are the graphs I got:
          Click image for larger version

Name:	Lowess (state_leg_fsi).png
Views:	1
Size:	139.9 KB
ID:	1643925



          Click image for larger version

Name:	Lowess (mil_yrs).png
Views:	1
Size:	141.1 KB
ID:	1643926




          Please, you had said something about fitting separate linear regressions at the left and right edges of the distribution of the explanatory variable to see if they have opposite signs. I would like to know how I can run that analyses as an alternative or check to what I have. These are the commands I have for my models:

          Model C: mixed cont_pol_mn i.female##c.state_leg_fsi##c.state_leg_fsi urban resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi || countrylvl:female, cov(unstr) vce(robust)
          Model D: mixed cont_pol_mn i.female##c.state_leg_fsi urban resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi || countrylvl:female, cov(unstr) vce(robust)

          Which of the models should I use? How do I write my commands to fit separate linear regression on the left and right with the chosen model? When I run them, what should I be looking out for?

          Thank you.

          Eugene.

          Comment


          • #20
            I also tried what I assumed is fit separate regression models on opposite sides of the data (I did this on the country-level variable, in my case). The following are the commands I used:

            * Recode State legitimacy to create two divisions of similar parts
            tab state_leg_fsi, nol
            recode state_leg_fsi (3.2/7.3=1) (7.4/9.9=2), gen (state_leg_fsi2)
            label variable state_leg_fsi "State legitimacy (binary)"
            tab state_leg_fsi
            tab state_leg_fsi2

            * Regression model for the first part
            mixed cont_pol_mn i.female##c.state_leg_fsi##c.state_leg_fsi urban ///
            resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi ///
            if state_leg_fsi2 == 1 || countrylvl:female, cov(unstr)
            est restore mod_a
            margins female, at(state_leg_fsi=(0 (1) 8)) atmeans
            est store mod_a_graph
            marginsplot, x(state_leg_fsi) title(Gender & State leg) ///
            xlabel(0(1)8) xtitle("State legitimacy") ///
            ytitle("Contacting politicians") noci


            cont_pol_mn | Coef. Std. Err. z P>|z|
            -----------------+-----------------------------------------
            1.female | -.0052308 .1299001 -0.04 0.968
            state_leg_fsi | -.0138225 .0367981 -0.38 0.707
            |
            female#|
            c.state_leg_fsi |
            1 | -.0562419 .0473863 -1.19 0.235
            |
            c.state_leg_fsi#|
            c.state_leg_fsi | -.0028978 .003353 -0.86 0.387
            |
            female#|
            c.state_leg_fsi#|
            c.state_leg_fsi |
            1 | .0062954 .0042824 1.47 0.142



            State_leg_part 1.png


            * Regression model for the second part
            mixed cont_pol_mn i.female##c.state_leg_fsi##c.state_leg_fsi urban resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi if state_leg_fsi2 == 1 || countrylvl:female, cov(unstr)
            est store mod_a
            margins female, at(state_leg_fsi=(7 (0.5) 10)) atmeans
            est store mod_a_graph
            marginsplot, x(state_leg_fsi) title(Gender & State leg) xlabel(7 (0.5) 10) xtitle("State legitimacy") ///
            ytitle("Contacting politicians") noci

            cont_pol_mn | Coef. Std. Err. z P>|z|
            -----------------+------------------------------------------
            1.female | -1.220524 .7763491 -1.57 0.116
            state_leg_fsi | -1.213955 .1619711 -7.49 0.000
            |
            female#|
            c.state_leg_fsi |
            1 | .2601833 .1821403 1.43 0.153
            |
            c.state_leg_fsi#|
            c.state_leg_fsi | .072143 .0095603 7.55 0.000
            |
            female#|
            c.state_leg_fsi#|
            c.state_leg_fsi |
            1 | -.0148515 .0106105 -1.40 0.162


            State_leg_part 2.png


            Please, what do you think? Was this done correctly?

            Eugene.

            Comment


            • #21
              Re #19. This does look somewhat like a quadratic relationship, in that there is a clear turning point in the middle of the data. It is rather asymmetric, however, and at least for men, the relationship looks nearly flat in the lower range of military years in country. Of course, the -loess- command does not adjust for covariates, let alone account for hierarchy, so it makes sense to follow-up on this with Simonsohn's approach.

              Which brings us to #20. Simonsohn's article is not easy to read; it took me several attempts before I felt I understood it. What you did is correct in some ways, but not in others. Here, I'll walk through the approach, first in words, and then with pseudo-code. I'm using pseudo-code here because I don't have a suitable data set to work with to write actual code that will work with your data, and I don't want to get bogged down in things like correctly typing the names of every variable and paying attention to peculiarities of syntax of particular commands. My goal here is to give you a good start in the direction of writing the code yourself by filling in the details.

              For simplicity I'm going to denote the outcome variable non-electoral participation as Y, and the key independent variable (which is state_leg_fsi for one analysis and civpt_mn_mil_yrs for another) as X. You should do this separately for each of the different X's, and also separately for men and women. (So at the top level you will loop over varlist state_leg_fsi civpt_mn_mil_yrs, and within that over values of female.) Within those loops (or you can just make 4 copies of the code and substitute the appropriate variables/values of sex if that's easier) you have to carry out several steps.

              Step 1. Identify an approximate turning point for the X:Y relationship. The kind of thing you did earlier in this thread is one approach, but let's do it Simonsohn's way, which means using a linear spline and then identifying the nadir (in his article, he is looking at invert-U relationships, so he speaks of the peak). He does that by transforming X with restricted cubic splines. There is another wrinkle we have to overcome: the random effect at the country level will be problematic in later steps since it will end up giving undue weight to the countries with the lowest values of the intercept. So I think we need to first demean the data within country and then use regress. Something like this will do these steps:

              Code:
              by country_lvl, sort: egen Y_mean = mean(Y)
              gen Y_demeaned = Y - Y_mean
              mkspline X_spline = X, cubic
              regress Y_demeaned c.(X_spline*) the_usual_covariates
              predict Yhat, xb
              Note that there are several simplifications to the original model. The quadratic terms are not used at all: the cubic spline will capture curvature, and far more flexibly. In addition, we use -regress- instead of -mixed-. This is because we are only interested in the shape of the relationship. The random intercepts and random slopes on gender don't have much effect on that, and using -regress- simplifies the later calculations. Once you have gotten this far, the minimum value of Yhat locates the Y value corresponding to any turning point. The next step is to identify the values of X that produce Yhat values within 1 standard deviation of that. The median value of that range of X's is Simonsohn's first approximation to a turning point. So,
              Code:
              summ Yhat
              local nadir = r(min)
              local ysd = r(sd)
              summ X if inrange(Yhat, `nadir'-`ysd', `nadir'+`ysd'), detail
              local x_left = r(min)
              local x_right = r(max)
              local x_middle = r(p50)
              Now we are ready to go ahead and do left (to the left of `x_middle') and right (to the right of `x_middle') regressions:
              Code:
              regress Y_demeaned X the_usual_covariates if X < `x_middle'
              matrix M = r(table)
              local t_left = M["t", "X"]
              regress Y_demeaned X the_usual_covariates if X > `x_middle'
              local t_right = M["t", "X"]
              Following each regression we have captured the t-statistic associated with the slope of X in these one-sided regressions.

              Now we use these to calculate a "more powerful" estimate of the turning point:
              Code:
              local percentile = round(100*`t_right'/(`t_left'+`t_right'))
              centile X if inrange(Yhat, `nadir'-`ysd', `nadir'+`ysd'), centile(`percentile')
              local x_middle = r(c_1)
              Now `x_middle' is the improved estimate of a turning point, and we now do regressions to the left and right of those.

              Code:
              regress Y_demeaned X the_usual_covariates if X < `x_middle'
              regress Y_demeaned X the_usual_covariates if X > `x_middle'
              To conclude there is a U-shaped relationship you want the coefficients of X from these two regressions to be "statistically significant" and of opposite signs. If that is not what you find, then you will need to explore other transformations of X that capture some curvilinearity without reaching a turning point.

              Comment


              • #22
                These were the codes I was able to write so far:

                by countrylvl, sort: egen ep_tot2_mean = mean(ep_tot2)
                gen ep_tot2_demeaned = ep_tot2 - ep_tot2_mean
                mkspline state_leg_spline = state_leg_fsi, cubic
                regress ep_tot2_demeaned c.state_leg_spline* i.female urban ///
                resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi
                predict Yhat, xb

                summ Yhat
                local nadir = r(min)
                local ysd = r(sd)
                summ state_leg_fsi if inrange(Yhat, `nadir'-`ysd', `nadir'+`ysd'), detail
                local x_left = r(min)
                local x_right = r(max)
                local x_middle = r(p50)

                regress ep_tot2_demeaned state_leg_fsi i.female urban resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi if state_leg_fsi < `x_middle'
                matrix M = r(table)
                local t_left = M["t", "X"]
                regress ep_tot2_demeaned state_leg_fsi i.female urban ///
                resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi ///
                if state_leg_fsi > `x_middle'
                local t_right = M["t", "X"]


                I was not able to run the code beyond the regression model of: regress ep_tot2_demeaned state_leg_fsi i.female urban resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi if state_leg_fsi < `x_middle'

                To be honest, this whole procedure is too complicated for my understanding. I hoped it would be something I could understand and run intuitively but it is not. You are an esteemed Professor, and you admit that the article was challenging for you. I am sure you will be kind enough to consider how difficult such an article is for me, a graduate student. Even if I am able to run the alternative approach you are suggesting, I cannot explain it. As you know, I will still have to write a method section where I describe what I am doing in my own words. I do not know what the approach you are suggesting means. I wish I did, but I don't. Also, I am yet to get any literature that tells the name of the issue I am dealing with. I am also yet to get any literature that tells me that my approach to the issue is wrong. I am open to running the right commands for the alternative approach you are suggesting. However, I cannot lie and I would respectfully say that I do not understand it and I cannot explain it.

                I asked other quantitative methodologists about this issue and they suggested that I could control for the square term in the model. Interestingly, that model gives me a margins plot graph similar to what I would obtain if I were to run the three-way interaction (i.e. the non-linear model). The AIC/BIC and lrtests I run for the models support it, as I have shown you before. I can show you the tests and margin plots again for your perusal, even though I sense that you would disagree with them. However, that is an approach and test that I can understand and explain. I am not simply making this point due to convenience, I am only reiterating what I said in previous posts that I will only follow an approach I can defend with the most evidence I have. If I do not have the evidence that what I am doing is wrong, I do not have the reason to turn away from it.

                Nevertheless, I am always open to running the models with the alternative approach you suggested.

                Thank you Professor and I look forward to your reply.

                Eugene Emeka Dim.

                Comment


                • #23
                  Fair enough. So let's take a step back again. For whatever reason, you decided to examine non-linearity and began with a quadratic model. But you weren't sure how to interpret the results. You've received advice, sometimes perhaps conflicting, from different people--in part because these things are not entirely cut-and-dried. Your -marginsplot-s from the quadratic models look nice, but they always do--they're just saying what the model predictions are, and provide no information about whether the model is a decent fit to the data or not. The -loess- plots suggest something different than a true quadratic, but it is not dispositive because it does not account for the covariates. The Simonsohn method is complicated.

                  I want to ask you to think back carefully about why you started down this path in the first place? What was it that led you to suspect that a non-linear relationship might be needed for this data? You said it did not come from the literature. Where did it come from? This may prove helpful ultimately.

                  Meanwhile, here's something else you can try. A very flexible way to capture non-linear relationships in regression is with restricted cubic splines. The problem is they are difficult to interpret, and they do not play nicely with -margins-. But we can work around that.
                  Code:
                  mkspline spline = state_leg_fsi, cubic
                  mixed cont_pol_mn i.female##c.(spline*) i.urban ///
                      resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi ///
                      || countrylvl:female, cov(unstr)
                  Note that the -mixed- command is exactly your regression, just with c.(spline*) replacing c.state_leg_fsi##c.state_leg_fsi.

                  Next, it looks from one of the graphs above that state_leg_fsi ranges from 0 through 8 and takes on integer values. So we can do for margins as follows:

                  Code:
                  local state_leg_values 0 1 2 3 4 5 6 7 8
                  ds spline*
                  local spline_vars `r(varlist)'
                  
                  //    CONSTRUCT AN -at()- FOR EACH VALUE OF STATE_LEG_FSI TO USE IN -margins-
                  local ats
                  foreach s of local state_leg_values {
                      local atspec at(
                      foreach v of local spline_vars {
                          summ `v' if state_leg_fsi == `s', meanonly
                          if r(n) > 0 {
                              local atspec `atspec' `v' = `r(mean)'
                          }
                      }
                      local atspec `atspec')
                      display `"`atspec'"'
                      local ats `ats' `atspec'
                      display `"`ats'
                  }
                  
                  //    NOW RUN -margins- AND GET A PLOT
                  margins female, `ats' nose // nose SAVES TIME IN LARGE DATA SETS & MIXED MODELS
                  marginsplot, xdimension(_at)
                  Now, the -display- commands are simply so you can see how the code is building up the contents of the -at()- option that will be used for -margins-. After -marginsplot- runs, you will get an error message about there being multiple at() options specified. Ignore that. Also the labeling of the x-axis of the graph will be an unreadable mess. Don't worry about that. What we want to see here is the shape of the graph. This will gives us the best practical view of just what kind of nonlinearity, and how much nonlinearity, there is in this relationship. Then we can decide from there what to do next.

                  The military variable is harder because it appears to skip over values in its range from 0 to 50. In fact, it looks like it only takes on 21 distinct values and they are not all that equally spaced. I suggest just doing
                  Code:
                  levelsof mil_yrs if e(sample), local(mil_yrs_values)
                  to create the list of values for that. The code will use all 21 instantiated values. The fact that the values are not equally spaced will cause the graph to be a bit distorted, because they will be plotted as if they were equally spaced, but I think it will still show us the general picture well enough.

                  I want to emphasize that this is an exploratory analysis, and it is not a test of any particular model. Its purpose is to guide picking out a model to test that we can have some confidence is a reasonable specification of the relationships you are focused on.


                  Comment


                  • #24
                    I can interpret the results of the non-linear model from my analyses. I wanted to know which of the models I could use, as I did not want to place a misspecified model in my research thesis.

                    You said: I want to ask you to think back carefully about why you started down this path in the first place? What was it that led you to suspect that a non-linear relationship might be needed for this data? You said it did not come from the literature. Where did it come from? This may prove helpful ultimately.
                    To be honest, I threw in the square variable out of sheer curiosity. The literature is silent on the kind of relationships I am looking at, i.e. the effect of the interaction between gender and political context on political participation. The most the literature has suggested is the idea that political openness will assume a curvilinear relationship with political participation (mind you, it does not include gender in this argument). However, there are very few results that looked like a curvilinear relationship. Also, most of the literature in this field is based on Western societies. My study explores the subject in Africa, and I intended my research partly as an exploration and partly as an explanatory piece. I have a sense that what obtains in my continent will not apply to Western societies, hence, why I am doing my research.

                    I ran the codes you sent to me and this was what I got:

                    . // NOW RUN -margins- AND GET A PLOT
                    . margins female, `ats' nose // nose SAVES TIME IN LARGE DATA SETS & MIXED MODELS
                    'spline2' found where number expected
                    r(7);



                    Please, is there a mistake somewhere?

                    I ran this commands (i.e., the one you gave me):

                    * The Spline model
                    mkspline spline = state_leg_fsi, cubic
                    mixed cont_pol_mn i.female##c.(spline*) i.urban ///
                    resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi ///
                    || countrylvl:female, cov(unstr)

                    local state_leg_values 0 1 2 3 4 5 6 7 8 9 10
                    ds spline*
                    local spline_vars `r(varlist)'

                    // CONSTRUCT AN -at()- FOR EACH VALUE OF STATE_LEG_FSI TO USE IN -margins-
                    local ats
                    foreach s of local state_leg_values {
                    local atspec at(
                    foreach v of local spline_vars {
                    summ `v' if state_leg_fsi == `s', meanonly
                    if r(n) > 0 {
                    local atspec `atspec' `v' = `r(mean)'
                    }
                    }
                    local atspec `atspec')
                    display `"`atspec'"'
                    local ats `ats' `atspec'
                    display `"`ats'
                    }

                    // NOW RUN -margins- AND GET A PLOT
                    margins female, `ats' nose // nose SAVES TIME IN LARGE DATA SETS & MIXED MODELS
                    marginsplot, xdimension(_at)




                    State legitimacy is actually an index from 0 to 10. I also ran he command on years of the military and I got this:

                    . levelsof mil_yrs if e(sample), local(mil_yrs_values)
                    0 1 2 4 6 7 8 9 13 16 22 23 24 25 29 32 35 38 44 47 48



                    Please, how do you suggest I proceed with the years under the military variable?

                    Comment


                    • #25
                      Well, something went wrong. I think I see a typo in the code. The line that says -if `r(n)' > 0 {- should read -if `r(N)' > 0 {-. (My error, sorry about that.)

                      If that change doesn't solve the problem, to help with the troubleshooting, please post back with all of the output you got from Stata when running this code. I need to see what came out of all those -display- commands that were in the loop to see why it didn't work as intended.
                      Last edited by Clyde Schechter; 09 Jan 2022, 11:47.

                      Comment


                      • #26
                        These are the commands I ran:
                        * The Spline model
                        mkspline spline = state_leg_fsi, cubic
                        mixed cont_pol_mn i.female##c.(spline*) i.urban ///
                        resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi ///
                        || countrylvl:female, cov(unstr)

                        local state_leg_values 0 1 2 3 4 5 6 7 8 9 10
                        ds spline*
                        local spline_vars `r(varlist)'

                        // CONSTRUCT AN -at()- FOR EACH VALUE OF STATE_LEG_FSI TO USE IN -margins-
                        local ats
                        foreach s of local state_leg_values {
                        local atspec at(
                        foreach v of local spline_vars {
                        summ `v' if state_leg_fsi == `s', meanonly
                        if `r(N)' > 0 {
                        local atspec `atspec' `v' = `r(mean)'
                        }
                        }
                        local atspec `atspec')
                        display `"`atspec'"'
                        local ats `ats' `atspec'
                        display `"`ats'
                        }

                        // NOW RUN -margins- AND GET A PLOT
                        margins female, `ats' nose // nose SAVES TIME IN LARGE DATA SETS & MIXED MODELS
                        marginsplot, xdimension(_at)




                        And this was the result I got:

                        . mixed cont_pol_mn i.female##c.(spline*) i.urban ///
                        > resp_age employed i.educ i.partisan i.volun dep_index i.wv log_gni gen_hdi ///
                        > || countrylvl:female, cov(unstr)

                        Performing EM optimization:

                        Performing gradient-based optimization:

                        Iteration 0: log likelihood = -110642.59
                        Iteration 1: log likelihood = -110642.59

                        Computing standard errors:

                        Mixed-effects ML regression Number of obs = 145,170
                        Group variable: countrylvl Number of groups = 36

                        Obs per group:
                        min = 1,180
                        avg = 4,032.5
                        max = 7,144

                        Wald chi2(23) = 14514.24
                        Log likelihood = -110642.59 Prob > chi2 = 0.0000

                        ----------------------------------------------------------------------------------
                        cont_pol_mn | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                        -----------------+----------------------------------------------------------------
                        1.female | -.111571 .0561919 -1.99 0.047 -.221705 -.001437
                        spline1 | -.0291702 .0090656 -3.22 0.001 -.0469385 -.0114019
                        spline2 | .0570854 .0449447 1.27 0.204 -.0310047 .1451754
                        spline3 | -.3298509 .2200198 -1.50 0.134 -.7610817 .1013799
                        spline4 | .9593674 .4592321 2.09 0.037 .0592889 1.859446
                        |
                        female#c.spline1 |
                        1 | -.0020251 .0106052 -0.19 0.849 -.022811 .0187607
                        |
                        female#c.spline2 |
                        1 | .0545454 .05671 0.96 0.336 -.0566042 .1656951
                        |
                        female#c.spline3 |
                        1 | -.1790945 .2744123 -0.65 0.514 -.7169328 .3587437
                        |
                        female#c.spline4 |
                        1 | .1327366 .5663706 0.23 0.815 -.9773293 1.242803
                        |
                        1.urban | -.0453192 .0030489 -14.86 0.000 -.0512949 -.0393435
                        resp_age | .0031 .0000997 31.09 0.000 .0029046 .0032954
                        employed | .0409212 .0030599 13.37 0.000 .034924 .0469184
                        |
                        educ |
                        Primary | .0685981 .0036169 18.97 0.000 .061509 .0756871
                        Secondary | .1048695 .0043847 23.92 0.000 .0962756 .1134633
                        University | .1753571 .0057114 30.70 0.000 .164163 .1865511
                        |
                        1.partisan | .1442442 .0029147 49.49 0.000 .1385314 .1499569
                        |
                        volun |
                        Inactive | .111548 .0042861 26.03 0.000 .1031474 .1199485
                        Active | .2865188 .0034781 82.38 0.000 .2797019 .2933357
                        |
                        dep_index | .0317557 .0018313 17.34 0.000 .0281664 .035345
                        |
                        wv |
                        6 | -.0190147 .0038239 -4.97 0.000 -.0265093 -.0115201
                        7 | .0055297 .0046371 1.19 0.233 -.0035588 .0146182
                        |
                        log_gni | .0154646 .0105058 1.47 0.141 -.0051264 .0360556
                        gen_hdi | .4480218 .1029577 4.35 0.000 .2462284 .6498153
                        _cons | -.3565814 .1284855 -2.78 0.006 -.6084084 -.1047544
                        ----------------------------------------------------------------------------------

                        ------------------------------------------------------------------------------
                        Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
                        -----------------------------+------------------------------------------------
                        countrylvl: Unstructured |
                        var(female) | .0014865 .0004276 .0008459 .0026121
                        var(_cons) | .0074193 .0019425 .0044413 .0123942
                        cov(female,_cons) | -.0024305 .0008017 -.0040018 -.0008592
                        -----------------------------+------------------------------------------------
                        var(Residual) | .2684733 .0009968 .2665268 .2704341
                        ------------------------------------------------------------------------------
                        LR test vs. linear model: chi2(3) = 1728.26 Prob > chi2 = 0.0000

                        Note: LR test is conservative and provided only for reference.

                        .
                        . local state_leg_values 0 1 2 3 4 5 6 7 8 9 10

                        . ds spline*
                        spline1 spline2 spline3 spline4

                        . local spline_vars `r(varlist)'

                        .
                        . // CONSTRUCT AN -at()- FOR EACH VALUE OF STATE_LEG_FSI TO USE IN -margins-
                        . local ats

                        . foreach s of local state_leg_values {
                        2. local atspec at(
                        3. foreach v of local spline_vars {
                        4. summ `v' if state_leg_fsi == `s', meanonly
                        5. if `r(N)' > 0 {
                        6. local atspec `atspec' `v' = `r(mean)'
                        7. }
                        8. }
                        9. local atspec `atspec')
                        10. display `"`atspec'"'
                        11. local ats `ats' `atspec'
                        12. display `"`ats'
                        13. }
                        at()
                        at()
                        at()
                        at() at()
                        at()
                        at() at() at()
                        at()
                        at() at() at() at()
                        at()
                        at() at() at() at() at()
                        at( spline1 = 5 spline2 = .0011245333589613 spline3 = 0 spline4 = 0)
                        at() at() at() at() at() at( spline1 = 5 spline2 = .0011245333589613 spline3 = 0 splin
                        > e4 = 0)
                        at( spline1 = 6 spline2 = .0915035605430603 spline3 = 0 spline4 = 0)
                        at() at() at() at() at() at( spline1 = 5 spline2 = .0011245333589613 spline3 = 0 splin
                        > e4 = 0) at( spline1 = 6 spline2 = .0915035605430603 spline3 = 0 spline4 = 0)
                        at( spline1 = 7 spline2 = .5067471861839294 spline3 = .0213244576007128 spline4 = 0)
                        at() at() at() at() at() at( spline1 = 5 spline2 = .0011245333589613 spline3 = 0 splin
                        > e4 = 0) at( spline1 = 6 spline2 = .0915035605430603 spline3 = 0 spline4 = 0) at( spl
                        > ine1 = 7 spline2 = .5067471861839294 spline3 = .0213244576007128 spline4 = 0)
                        at( spline1 = 8 spline2 = 1.496751308441162 spline3 = .2428988069295883 spline4 = .014
                        > 2856994643807)
                        at() at() at() at() at() at( spline1 = 5 spline2 = .0011245333589613 spline3 = 0 splin
                        > e4 = 0) at( spline1 = 6 spline2 = .0915035605430603 spline3 = 0 spline4 = 0) at( spl
                        > ine1 = 7 spline2 = .5067471861839294 spline3 = .0213244576007128 spline4 = 0) at( sp
                        > line1 = 8 spline2 = 1.496751308441162 spline3 = .2428988069295883 spline4 = .0142856
                        > 994643807)
                        at( spline1 = 9 spline2 = 3.212228059768677 spline3 = .8454644680023193 spline4 = .158
                        > 0674201250076)
                        at() at() at() at() at() at( spline1 = 5 spline2 = .0011245333589613 spline3 = 0 splin
                        > e4 = 0) at( spline1 = 6 spline2 = .0915035605430603 spline3 = 0 spline4 = 0) at( spl
                        > ine1 = 7 spline2 = .5067471861839294 spline3 = .0213244576007128 spline4 = 0) at( sp
                        > line1 = 8 spline2 = 1.496751308441162 spline3 = .2428988069295883 spline4 = .0142856
                        > 994643807) at( spline1 = 9 spline2 = 3.212228059768677 spline3 = .8454644680023193 s
                        > pline4 = .1580674201250076)
                        at()
                        at() at() at() at() at() at( spline1 = 5 spline2 = .0011245333589613 spline3 = 0 splin
                        > e4 = 0) at( spline1 = 6 spline2 = .0915035605430603 spline3 = 0 spline4 = 0) at( spl
                        > ine1 = 7 spline2 = .5067471861839294 spline3 = .0213244576007128 spline4 = 0) at( sp
                        > line1 = 8 spline2 = 1.496751308441162 spline3 = .2428988069295883 spline4 = .0142856
                        > 994643807) at( spline1 = 9 spline2 = 3.212228059768677 spline3 = .8454644680023193 s
                        > pline4 = .1580674201250076) at()

                        .
                        . // NOW RUN -margins- AND GET A PLOT
                        . margins female, `ats' nose // nose SAVES TIME IN LARGE DATA SETS & MIXED MODELS
                        option at() not allowed
                        r(198);



                        Comment


                        • #27
                          OK, I think I see the problem. I had assumed, based on the -marginsplot- output from an earlier post in the thread, that state_leg_fsi took on all integer values from 0 through 108. But that seems to be incorrect. From the output I am seeing, it appears that only values 5, 6, 7, 8, and 9 actually occur. So to fix this, replace the line
                          Code:
                          local state_leg_values 0 1 2 3 4 5 6 7 8 9 10
                          


                          with
                          Code:
                          levelsof state_leg_fsi if e(sample), local(state_leg_values)

                          Comment


                          • #28
                            I ran the model with that change and, after the regression table, I got this results:

                            .
                            . levelsof state_leg_fsi if e(sample), local(state_leg_values)
                            3.200000047683716 3.5 4.099999904632568 4.400000095367432 4.699999809265137 4.80000019
                            > 0734863 5 5.099999904632568 5.199999809265137 5.300000190734863 5.400000095367432 5.
                            > 5 5.800000190734863 5.900000095367432 6 6.099999904632568 6.199999809265137 6.300000
                            > 190734863 6.400000095367432 6.5 6.599999904632568 6.699999809265137 6.80000019073486
                            > 3 7 7.099999904632568 7.199999809265137 7.300000190734863 7.400000095367432 7.5 7.59
                            > 9999904632568 7.699999809265137 7.800000190734863 7.900000095367432 8 8.100000381469
                            > 727 8.300000190734863 8.399999618530273 8.5 8.699999809265137 8.800000190734863 8.89
                            > 9999618530273 9 9.199999809265137 9.300000190734863 9.399999618530273 9.600000381469
                            > 727 9.800000190734863 9.899999618530273

                            . ds spline*
                            spline1 spline2 spline3 spline4

                            . local spline_vars `r(varlist)'

                            .
                            . // CONSTRUCT AN -at()- FOR EACH VALUE OF STATE_LEG_FSI TO USE IN -margins-
                            . local ats

                            . foreach s of local state_leg_values {
                            2. local atspec at(
                            3. foreach v of local spline_vars {
                            4. summ `v' if state_leg_fsi == `s', meanonly
                            5. if `r(N)' > 0 {
                            6. local atspec `atspec' `v' = `r(mean)'
                            7. }
                            8. }
                            9. local atspec `atspec')
                            10. display `"`atspec'"'
                            11. local ats `ats' `atspec'
                            12. display `"`ats'
                            13. }

                            at( spline1 = 3.200000047683716 spline2 = 0 spline3 = 0 spline4 = 0)
                            at( spline1 = 3.200000047683716 spline2 = 0 spline3 = 0 spline4 = 0)
                            at( spline1 = 3.5 spline2 = 0 spline3 = 0 spline4 = 0)
                            at( spline1 = 3.200000047683716 spline2 = 0 spline3 = 0 spline4 = 0) at( spline1 = 3.5
                            > spline2 = 0 spline3 = 0 spline4 = 0)
                            at( spline1 = 4.099999904632568 spline2 = 0 spline3 = 0 spline4 = 0)
                            at( spline1 = 3.200000047683716 spline2 = 0 spline3 = 0 spline4 = 0) at( spline1 = 3.5
                            > spline2 = 0 spline3 = 0 spline4 = 0) at( spline1 = 4.099999904632568 spline2 = 0 sp
                            > line3 = 0 spline4 = 0)
                            at( spline1 = 4.400000095367432 spline2 = 0 spline3 = 0 spline4 = 0)
                            at( spline1 = 3.200000047683716 spline2 = 0 spline3 = 0 spline4 = 0) at( spline1 = 3.5
                            > spline2 = 0 spline3 = 0 spline4 = 0) at( spline1 = 4.099999904632568 spline2 = 0 sp
                            > line3 = 0 spline4 = 0) at( spline1 = 4.400000095367432 spline2 = 0 spline3 = 0 splin
                            > e4 = 0)


                            (CUT DUE TO THE WORD LIMIT)

                            at( spline1 = 3.200000047683716 spline2 = 0 spline3 = 0 spline4 = 0) at( spline1 = 3.5
                            > spline2 = 0 spline3 = 0 spline4 = 0) at( spline1 = 4.099999904632568 spline2 = 0 sp
                            > line3 = 0 spline4 = 0) at( spline1 = 4.400000095367432 spline2 = 0 spline3 = 0 splin
                            > e4 = 0) at( spline1 = 4.699999809265137 spline2 = 0 spline3 = 0 spline4 = 0) at( spl
                            > ine1 = 4.800000190734863 spline2 = .0000416497787228 spline3 = 0 spline4 = 0) at( sp
                            > line1 = 5 spline2 = .0011245333589613 spline3 = 0 spline4 = 0) at( spline1 = 5.09999
                            > 9904632568 spline2 = .0026655572000891 spline3 = 0 spline4 = 0) at( spline1 = 5.1999
                            > 99809265137 spline2 = .0052061630412936 spline3 = 0 spline4 = 0) at( spline1 = 5.300
                            > 000190734863 spline2 = .0089962668716908 spline3 = 0 spline4 = 0) at( spline1 = 5.40
                            > 0000095367432 spline2 = .0142857283353806 spline3 = 0 spline4 = 0) at( spline1 = 5.5
                            > spline2 = .0213244576007128 spline3 = 0 spline4 = 0) at( spline1 = 5.80000019073486
                            > 3 spline2 = .0554352812469006 spline3 = 0 spline4 = 0) at( spline1 = 5.9000000953674
                            > 32 spline2 = .0719700455665588 spline3 = 0 spline4 = 0) at( spline1 = 6 spline2 = .0
                            > 915035605430603 spline3 = 0 spline4 = 0) at( spline1 = 6.099999904632568 spline2 = .
                            > 1142857074737549 spline3 = 0 spline4 = 0) at( spline1 = 6.199999809265137 spline2 =
                            > .1405663937330246 spline3 = 0 spline4 = 0) at( spline1 = 6.300000190734863 spline2 =
                            > .1705956608057022 spline3 = .0000416497787228 spline4 = 0) at( spline1 = 6.40000009
                            > 5367432 spline2 = .2046231329441071 spline3 = .0003331958432682 spline4 = 0) at( spl
                            > ine1 = 6.5 spline2 = .2428988069295883 spline3 = .0011245333589613 spline4 = 0) at(
                            > spline1 = 6.599999904632568 spline2 = .2856726050376892 spline3 = .0026655572000891
                            > spline4 = 0) at( spline1 = 6.699999809265137 spline2 = .3331944346427917 spline3 = .
                            > 0052061630412936 spline4 = 0) at( spline1 = 6.800000190734863 spline2 = .38571441173
                            > 55347 spline3 = .0089962668716908 spline4 = 0) at( spline1 = 7 spline2 = .5067471861
                            > 839294 spline3 = .0213244576007128 spline4 = 0) at( spline1 = 7.099999904632568 spli
                            > ne2 = .5757600069046021 spline3 = .0303623508661985 spline4 = 0) at( spline1 = 7.199
                            > 999809265137 spline2 = .650770366191864 spline3 = .041649304330349 spline4 = 0) at(
                            > spline1 = 7.300000190734863 spline2 = .7320284843444824 spline3 = .0554352812469006
                            > spline4 = 0) at( spline1 = 7.400000095367432 spline2 = .8197835087776184 spline3 = .
                            > 0719700455665588 spline4 = .0000416491820943) at( spline1 = 7.5 spline2 = .914285659
                            > 7900391 spline3 = .0915035605430603 spline4 = .0003331934567541) at( spline1 = 7.599
                            > 999904632568 spline2 = 1.015784978866577 spline3 = .1142857074737549 spline4 = .0011
                            > 245280038565) at( spline1 = 7.699999809265137 spline2 = 1.124531149864197 spline3 =
                            > .1405663937330246 spline4 = .0026655476540327) at( spline1 = 7.800000190734863 splin
                            > e2 = 1.240774869918823 spline3 = .1705956608057022 spline4 = .0052061630412936) at(
                            > spline1 = 7.900000095367432 spline2 = 1.36476469039917 spline3 = .2046231329441071 s
                            > pline4 = .0089962454512715) at( spline1 = 8 spline2 = 1.496751308441162 spline3 = .2
                            > 428988069295883 spline4 = .0142856994643807) at( spline1 = 8.100000381469727 spline2
                            > = 1.636985063552856 spline3 = .2856728136539459 spline4 = .0213244576007128) at( sp
                            > line1 = 8.300000190734863 spline2 = 1.942102074623108 spline3 = .3849591612815857 sp
                            > line4 = .041138406842947) at( spline1 = 8.399999618530273 spline2 = 2.10598826408386
                            > 2 spline3 = .4409327507019043 spline4 = .0537108667194843) at( spline1 = 8.5 spline2
                            > = 2.276673555374146 spline3 = .5007053017616272 spline4 = .0678827911615372) at( sp
                            > line1 = 8.699999809265137 spline2 = 2.636167764663696 spline3 = .6303789019584656 sp
                            > line4 = .1004913821816444) at( spline1 = 8.800000190734863 spline2 = 2.8238458633422
                            > 85 spline3 = .6996475458145142 spline4 = .1186616569757462) at( spline1 = 8.89999961
                            > 8530273 spline2 = 3.016053438186646 spline3 = .7714477777481079 spline4 = .137897968
                            > 2922363) at( spline1 = 9 spline2 = 3.212228059768677 spline3 = .8454644680023193 spl
                            > ine4 = .1580674201250076) at( spline1 = 9.199999809265137 spline2 = 3.61420464515686
                            > spline3 = .9988781809806824 spline4 = .2006718516349792) at( spline1 = 9.3000001907
                            > 34863 spline2 = 3.818875551223755 spline3 = 1.077642917633057 spline4 = .22284047305
                            > 58395) at( spline1 = 9.399999618530273 spline2 = 4.025244235992432 spline3 = 1.15735
                            > 650062561 spline4 = .2454087138175964) at( spline1 = 9.600000381469727 spline2 = 4.4
                            > 40816879272461 spline3 = 1.318367838859558 spline4 = .2912120223045349) at( spline1
                            > = 9.800000190734863 spline2 = 4.857142925262451 spline3 = 1.479800462722778 spline4
                            > = .3371928334236145)
                            at( spline1 = 9.899999618530273 spline2 = 5.065305233001709 spline3 = 1.56051635742187
                            > 5 spline4 = .3601831197738647)
                            at( spline1 = 3.200000047683716 spline2 = 0 spline3 = 0 spline4 = 0) at( spline1 = 3.5
                            > spline2 = 0 spline3 = 0 spline4 = 0) at( spline1 = 4.099999904632568 spline2 = 0 sp
                            > line3 = 0 spline4 = 0) at( spline1 = 4.400000095367432 spline2 = 0 spline3 = 0 splin
                            > e4 = 0) at( spline1 = 4.699999809265137 spline2 = 0 spline3 = 0 spline4 = 0) at( spl
                            > ine1 = 4.800000190734863 spline2 = .0000416497787228 spline3 = 0 spline4 = 0) at( sp
                            > line1 = 5 spline2 = .0011245333589613 spline3 = 0 spline4 = 0) at( spline1 = 5.09999
                            > 9904632568 spline2 = .0026655572000891 spline3 = 0 spline4 = 0) at( spline1 = 5.1999
                            > 99809265137 spline2 = .0052061630412936 spline3 = 0 spline4 = 0) at( spline1 = 5.300
                            > 000190734863 spline2 = .0089962668716908 spline3 = 0 spline4 = 0) at( spline1 = 5.40
                            > 0000095367432 spline2 = .0142857283353806 spline3 = 0 spline4 = 0) at( spline1 = 5.5
                            > spline2 = .0213244576007128 spline3 = 0 spline4 = 0) at( spline1 = 5.80000019073486
                            > 3 spline2 = .0554352812469006 spline3 = 0 spline4 = 0) at( spline1 = 5.9000000953674
                            > 32 spline2 = .0719700455665588 spline3 = 0 spline4 = 0) at( spline1 = 6 spline2 = .0
                            > 915035605430603 spline3 = 0 spline4 = 0) at( spline1 = 6.099999904632568 spline2 = .
                            > 1142857074737549 spline3 = 0 spline4 = 0) at( spline1 = 6.199999809265137 spline2 =
                            > .1405663937330246 spline3 = 0 spline4 = 0) at( spline1 = 6.300000190734863 spline2 =
                            > .1705956608057022 spline3 = .0000416497787228 spline4 = 0) at( spline1 = 6.40000009
                            > 5367432 spline2 = .2046231329441071 spline3 = .0003331958432682 spline4 = 0) at( spl
                            > ine1 = 6.5 spline2 = .2428988069295883 spline3 = .0011245333589613 spline4 = 0) at(
                            > spline1 = 6.599999904632568 spline2 = .2856726050376892 spline3 = .0026655572000891
                            > spline4 = 0) at( spline1 = 6.699999809265137 spline2 = .3331944346427917 spline3 = .
                            > 0052061630412936 spline4 = 0) at( spline1 = 6.800000190734863 spline2 = .38571441173
                            > 55347 spline3 = .0089962668716908 spline4 = 0) at( spline1 = 7 spline2 = .5067471861
                            > 839294 spline3 = .0213244576007128 spline4 = 0) at( spline1 = 7.099999904632568 spli
                            > ne2 = .5757600069046021 spline3 = .0303623508661985 spline4 = 0) at( spline1 = 7.199
                            > 999809265137 spline2 = .650770366191864 spline3 = .041649304330349 spline4 = 0) at(
                            > spline1 = 7.300000190734863 spline2 = .7320284843444824 spline3 = .0554352812469006
                            > spline4 = 0) at( spline1 = 7.400000095367432 spline2 = .8197835087776184 spline3 = .
                            > 0719700455665588 spline4 = .0000416491820943) at( spline1 = 7.5 spline2 = .914285659
                            > 7900391 spline3 = .0915035605430603 spline4 = .0003331934567541) at( spline1 = 7.599
                            > 999904632568 spline2 = 1.015784978866577 spline3 = .1142857074737549 spline4 = .0011
                            > 245280038565) at( spline1 = 7.699999809265137 spline2 = 1.124531149864197 spline3 =
                            > .1405663937330246 spline4 = .0026655476540327) at( spline1 = 7.800000190734863 splin
                            > e2 = 1.240774869918823 spline3 = .1705956608057022 spline4 = .0052061630412936) at(
                            > spline1 = 7.900000095367432 spline2 = 1.36476469039917 spline3 = .2046231329441071 s
                            > pline4 = .0089962454512715) at( spline1 = 8 spline2 = 1.496751308441162 spline3 = .2
                            > 428988069295883 spline4 = .0142856994643807) at( spline1 = 8.100000381469727 spline2
                            > = 1.636985063552856 spline3 = .2856728136539459 spline4 = .0213244576007128) at( sp
                            > line1 = 8.300000190734863 spline2 = 1.942102074623108 spline3 = .3849591612815857 sp
                            > line4 = .041138406842947) at( spline1 = 8.399999618530273 spline2 = 2.10598826408386
                            > 2 spline3 = .4409327507019043 spline4 = .0537108667194843) at( spline1 = 8.5 spline2
                            > = 2.276673555374146 spline3 = .5007053017616272 spline4 = .0678827911615372) at( sp
                            > line1 = 8.699999809265137 spline2 = 2.636167764663696 spline3 = .6303789019584656 sp
                            > line4 = .1004913821816444) at( spline1 = 8.800000190734863 spline2 = 2.8238458633422
                            > 85 spline3 = .6996475458145142 spline4 = .1186616569757462) at( spline1 = 8.89999961
                            > 8530273 spline2 = 3.016053438186646 spline3 = .7714477777481079 spline4 = .137897968
                            > 2922363) at( spline1 = 9 spline2 = 3.212228059768677 spline3 = .8454644680023193 spl
                            > ine4 = .1580674201250076) at( spline1 = 9.199999809265137 spline2 = 3.61420464515686
                            > spline3 = .9988781809806824 spline4 = .2006718516349792) at( spline1 = 9.3000001907
                            > 34863 spline2 = 3.818875551223755 spline3 = 1.077642917633057 spline4 = .22284047305
                            > 58395) at( spline1 = 9.399999618530273 spline2 = 4.025244235992432 spline3 = 1.15735
                            > 650062561 spline4 = .2454087138175964) at( spline1 = 9.600000381469727 spline2 = 4.4
                            > 40816879272461 spline3 = 1.318367838859558 spline4 = .2912120223045349) at( spline1
                            > = 9.800000190734863 spline2 = 4.857142925262451 spline3 = 1.479800462722778 spline4
                            > = .3371928334236145) at( spline1 = 9.899999618530273 spline2 = 5.065305233001709 spl
                            > ine3 = 1.560516357421875 spline4 = .3601831197738647)

                            .
                            . // NOW RUN -margins- AND GET A PLOT
                            . margins female, `ats' nose // nose SAVES TIME IN LARGE DATA SETS & MIXED MODELS

                            Predictive margins Number of obs = 145,170

                            Expression : Linear prediction, fixed portion, predict()

                            1._at : spline1 = 3.2
                            spline2 = 0
                            spline3 = 0
                            spline4 = 0

                            2._at : spline1 = 3.5
                            spline2 = 0
                            spline3 = 0
                            spline4 = 0

                            3._at : spline1 = 4.1
                            spline2 = 0
                            spline3 = 0
                            spline4 = 0

                            4._at : spline1 = 4.4
                            spline2 = 0
                            spline3 = 0
                            spline4 = 0

                            5._at : spline1 = 4.7
                            spline2 = 0
                            spline3 = 0
                            spline4 = 0

                            6._at : spline1 = 4.8
                            spline2 = .0000416
                            spline3 = 0
                            spline4 = 0

                            7._at : spline1 = 5
                            spline2 = .0011245
                            spline3 = 0
                            spline4 = 0

                            8._at : spline1 = 5.1
                            spline2 = .0026656
                            spline3 = 0
                            spline4 = 0

                            9._at : spline1 = 5.2
                            spline2 = .0052062
                            spline3 = 0
                            spline4 = 0

                            10._at : spline1 = 5.3
                            spline2 = .0089963
                            spline3 = 0
                            spline4 = 0

                            11._at : spline1 = 5.4
                            spline2 = .0142857
                            spline3 = 0
                            spline4 = 0

                            12._at : spline1 = 5.5
                            spline2 = .0213245
                            spline3 = 0
                            spline4 = 0

                            13._at : spline1 = 5.8
                            spline2 = .0554353
                            spline3 = 0
                            spline4 = 0

                            14._at : spline1 = 5.9
                            spline2 = .07197
                            spline3 = 0
                            spline4 = 0

                            15._at : spline1 = 6
                            spline2 = .0915036
                            spline3 = 0
                            spline4 = 0

                            16._at : spline1 = 6.1
                            spline2 = .1142857
                            spline3 = 0
                            spline4 = 0

                            17._at : spline1 = 6.2
                            spline2 = .1405664
                            spline3 = 0
                            spline4 = 0

                            18._at : spline1 = 6.3
                            spline2 = .1705957
                            spline3 = .0000416
                            spline4 = 0

                            19._at : spline1 = 6.4
                            spline2 = .2046231
                            spline3 = .0003332
                            spline4 = 0

                            20._at : spline1 = 6.5
                            spline2 = .2428988
                            spline3 = .0011245
                            spline4 = 0

                            21._at : spline1 = 6.6
                            spline2 = .2856726
                            spline3 = .0026656
                            spline4 = 0

                            22._at : spline1 = 6.7
                            spline2 = .3331944
                            spline3 = .0052062
                            spline4 = 0

                            23._at : spline1 = 6.8
                            spline2 = .3857144
                            spline3 = .0089963
                            spline4 = 0

                            24._at : spline1 = 7
                            spline2 = .5067472
                            spline3 = .0213245
                            spline4 = 0

                            25._at : spline1 = 7.1
                            spline2 = .57576
                            spline3 = .0303624
                            spline4 = 0

                            26._at : spline1 = 7.2
                            spline2 = .6507704
                            spline3 = .0416493
                            spline4 = 0

                            27._at : spline1 = 7.3
                            spline2 = .7320285
                            spline3 = .0554353
                            spline4 = 0

                            28._at : spline1 = 7.4
                            spline2 = .8197835
                            spline3 = .07197
                            spline4 = .0000416

                            29._at : spline1 = 7.5
                            spline2 = .9142857
                            spline3 = .0915036
                            spline4 = .0003332

                            30._at : spline1 = 7.6
                            spline2 = 1.015785
                            spline3 = .1142857
                            spline4 = .0011245

                            31._at : spline1 = 7.7
                            spline2 = 1.124531
                            spline3 = .1405664
                            spline4 = .0026655

                            32._at : spline1 = 7.8
                            spline2 = 1.240775
                            spline3 = .1705957
                            spline4 = .0052062

                            33._at : spline1 = 7.9
                            spline2 = 1.364765
                            spline3 = .2046231
                            spline4 = .0089962

                            34._at : spline1 = 8
                            spline2 = 1.496751
                            spline3 = .2428988
                            spline4 = .0142857

                            35._at : spline1 = 8.1
                            spline2 = 1.636985
                            spline3 = .2856728
                            spline4 = .0213245

                            36._at : spline1 = 8.3
                            spline2 = 1.942102
                            spline3 = .3849592
                            spline4 = .0411384

                            37._at : spline1 = 8.4
                            spline2 = 2.105988
                            spline3 = .4409328
                            spline4 = .0537109

                            38._at : spline1 = 8.5
                            spline2 = 2.276674
                            spline3 = .5007053
                            spline4 = .0678828

                            39._at : spline1 = 8.7
                            spline2 = 2.636168
                            spline3 = .6303789
                            spline4 = .1004914

                            40._at : spline1 = 8.8
                            spline2 = 2.823846
                            spline3 = .6996475
                            spline4 = .1186617

                            41._at : spline1 = 8.9
                            spline2 = 3.016053
                            spline3 = .7714478
                            spline4 = .137898

                            42._at : spline1 = 9
                            spline2 = 3.212228
                            spline3 = .8454645
                            spline4 = .1580674

                            43._at : spline1 = 9.2
                            spline2 = 3.614205
                            spline3 = .9988782
                            spline4 = .2006719

                            44._at : spline1 = 9.3
                            spline2 = 3.818876
                            spline3 = 1.077643
                            spline4 = .2228405

                            45._at : spline1 = 9.4
                            spline2 = 4.025244
                            spline3 = 1.157357
                            spline4 = .2454087

                            46._at : spline1 = 9.6
                            spline2 = 4.440817
                            spline3 = 1.318368
                            spline4 = .291212

                            47._at : spline1 = 9.8
                            spline2 = 4.857143
                            spline3 = 1.4798
                            spline4 = .3371928

                            48._at : spline1 = 9.9
                            spline2 = 5.065305
                            spline3 = 1.560516
                            spline4 = .3601831

                            ------------------------------------------------------------------------------
                            | Margin
                            -------------+----------------------------------------------------------------
                            _at#female |
                            1 0 | .4349872
                            1 1 | .3169358
                            2 0 | .4262361
                            2 1 | .3075772
                            3 0 | .408734
                            3 1 | .28886
                            4 0 | .399983
                            4 1 | .2795013
                            5 0 | .3912319
                            5 1 | .2701428
                            6 0 | .3883172
                            6 1 | .2670279
                            7 0 | .382545
                            7 1 | .2609097
                            8 0 | .379716
                            8 1 | .2579622
                            9 0 | .376944
                            9 1 | .2551263
                            10 0 | .3742433
                            10 1 | .2524298
                            11 0 | .3716283
                            11 1 | .2499007
                            12 0 | .369113
                            12 1 | .2475669
                            13 0 | .3623092
                            13 1 | .2420162
                            14 0 | .3603361
                            14 1 | .2407424
                            15 0 | .3585341
                            15 1 | .2398034
                            16 0 | .3569177
                            16 1 | .2392271
                            17 0 | .3555009
                            17 1 | .2390413
                            18 0 | .3542843
                            18 1 | .2392527
                            19 0 | .3532136
                            19 1 | .2397833
                            20 0 | .3522206
                            20 1 | .2405338
                            21 0 | .351237
                            21 1 | .2414048
                            22 0 | .3501948
                            22 1 | .2422972
                            23 0 | .3490257
                            23 1 | .2431115
                            24 0 | .3460344
                            24 1 | .2441091
                            25 0 | .3440758
                            25 1 | .2440937
                            26 0 | .3417178
                            26 1 | .2436032
                            27 0 | .3388921
                            27 1 | .2425383
                            28 0 | .3355706
                            28 1 | .2408451
                            29 0 | .3318848
                            29 1 | .2386518
                            30 0 | .3280064
                            30 1 | .2361321
                            31 0 | .3241069
                            31 1 | .2334595
                            32 0 | .3203579
                            32 1 | .2308077
                            33 0 | .3169309
                            33 1 | .2283503
                            34 0 | .3139977
                            34 1 | .2262609
                            35 0 | .3117297
                            35 1 | .2247132
                            36 0 | .3095725
                            36 1 | .2236421
                            37 0 | .3096097
                            37 1 | .2240603
                            38 0 | .3103163
                            38 1 | .2250507
                            39 0 | .3135148
                            39 1 | .2285575
                            40 0 | .3158951
                            40 1 | .2309785
                            41 0 | .3187217
                            41 1 | .2337809
                            42 0 | .3219388
                            42 1 | .2369172
                            43 0 | .3293214
                            43 1 | .2440003
                            44 0 | .3333753
                            44 1 | .2478519
                            45 0 | .3375966
                            45 1 | .2518464
                            46 0 | .3463181
                            46 1 | .2600741
                            47 0 | .355114
                            47 1 | .2683652
                            48 0 | .3595119
                            48 1 | .2725108
                            ------------------------------------------------------------------------------

                            . marginsplot, xdimension(_at)
                            _at not a dimension in margins results
                            r(322);

                            end of do-file

                            r(322);



                            Comment


                            • #29
                              I do not understand why -marginsplot- is doing that. But here's what we can do. Rerun the same code, but change the -margins- command to save its results in a file. Pick a filename to receive those results, let's say margins_results.dta, and change the -margins- command to:
                              [code]
                              margins female, `ats' nose saving(margins_results, replace)
                              [/code
                              Don't bother with -marginsplot- as we already know it doesn't like what we're giving it. Post back showing the contents of margins_results.dta using the -dataex- command, and then we can figure out what to tell -marginsplot- to do, or how to get a graph without -marginsplot-.

                              If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

                              Comment


                              • #30
                                Thank you for your response.

                                At this juncture, please I would like to stick with models D and E for my thesis at this point. I believe I have some statistical backing for those models. I have consulted with other statisticians who suggested the same. I know that these issues are not settled and are still debated. As I said in my previous posts, I will stick with the method I can understand and defend with the most evidence I have. As long as there is no consensus on what I should go with, I will follow the models I can understand and defend. I know that I can use the AIC/BIC and lrtests to defend the models. Also, Model E is somewhat a non-linear model that I can work with.

                                Thank you for your suggestions and advice thus far. It was great learning from you.

                                Eugene.

                                Comment

                                Working...
                                X