Announcement

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

  • Margins dxdy

    So I need to calculate the partial effect at the average and the average partial effect of a probit model.
    More specifically:
    1. Calculate the partial effect at the average of election day violence from the probit model (that is, calculate effect on the probability that fraud = 1 for a marginal increase in election viol for the “average” observation, by plugging in the mean of the X variables).
    2. As well as calculate the average partial effect of election day violence from the probit model (that is, calculate the partial effect on the probability that fraud = 1 for a marginal increase in election viol for each observation and take the mean).
    I have been using the code
    margins, dydx(fraud fraud_probit) atmeans

    but I keep getting:
    invalid dydx() option;
    fraud not found in list of covariates

    r(322);

    I have included my do file and the .csv
    Thanks for your help.
    Attached Files

  • #2
    I recommend you read the Forum FAQ and then post back. Follow the advice there on how best to show your code and example data, by using code delimiters and the -dataex- command, respectively.
    If you are running version 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.

    While your intent in attaching a do file and a .csv file were good, attachments here are strongly discouraged. If nothing else, people are often reluctant to download files from strangers. Also, the fact that you are already running Stata code tells me that you have imported your data into Stata. So the .csv file is not an appropriate data source here: the Stata data set, as represented by -dataex- is.

    All of that said, without having seen either your do-file or your data, making some simple assumptions about what your variables are, your -margins- command looks quite wrong. If you are looking for the partial effect of violence on some outcome modeled with probit, the command would be -margins, dydx(viol) atmeans-. The variable specified in -margins-' dydx() option is the "x" variable. The y variable is not specified because it is automatically taken to be the outcome variable of the regression that preceded it.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      I recommend you read the Forum FAQ and then post back. Follow the advice there on how best to show your code and example data, by using code delimiters and the -dataex- command, respectively.
      If you are running version 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.

      While your intent in attaching a do file and a .csv file were good, attachments here are strongly discouraged. If nothing else, people are often reluctant to download files from strangers. Also, the fact that you are already running Stata code tells me that you have imported your data into Stata. So the .csv file is not an appropriate data source here: the Stata data set, as represented by -dataex- is.

      All of that said, without having seen either your do-file or your data, making some simple assumptions about what your variables are, your -margins- command looks quite wrong. If you are looking for the partial effect of violence on some outcome modeled with probit, the command would be -margins, dydx(viol) atmeans-. The variable specified in -margins-' dydx() option is the "x" variable. The y variable is not specified because it is automatically taken to be the outcome variable of the regression that preceded it.
      Thanks Clyde! This was helpful in multiple ways

      Comment

      Working...
      X