Download Marginal effects

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Least squares wikipedia , lookup

Linear regression wikipedia , lookup

Regression analysis wikipedia , lookup

Coefficient of determination wikipedia , lookup

Transcript
Risk management in banking - University of Rome 3
Lecture #5: Binary model1
Binary responses (0 or 1) are modeled with logit and probit regressions.
Example, logit:
webuse lbw
describe
summarize
logit low smoke
ereturn list
In order to see the meaning of the saved results see help logit at the very end
Example, probit:
sysuse auto
describe
summarize
probit foreign weight
Predicted probabilities
use http://dss.princeton.edu/training/Panel101.dta
If you want to perform the command, but suppress the final output, type in the Command window:
quietly [:] command
Examples:
1)
qui logit y_bin x1 x2 x3 i.opinion
margins, atmeans post
1
This lecture is based on “Predicted probabilities and marginal effects after (ordered) logit/probit using margins
in Stata”, by Oscar Torres-Reyna, available at: http://www.princeton.edu/~otorres/Margins.pdf
Risk management in banking - University of Rome 3
You have generated variables at mean values.
In fact:
egen x1_mean=mean(x1)
br x1_mean
The probability of y_bin = 1 is 85% given that all predictors are set to their mean values.
2)
You can also choose to set a predictor to specific value:
qui logit y_bin x1 x2 x3 i.opinion
margins, at(x2=4) atmeans post
The probability of y_bin = 1 is 95% given that x2 = 4 and the other predictors are set to their mean
values.
3)
tab opinion
qui logit y_bin x1 x2 x3 i.opinion
margins, at(x2=4 x3=3 opinion=(3 4)) atmeans post
The probability of y_bin = 1 is 98% given that x2 = 4, x3 = 3, the opinion is “Disag” and the rest of
predictors are set to their mean values.
The probability of y_bin = 1 is 99% given that x2 = 4, x3 = 3, the opinion is “Str disag” and the rest of
predictors are set to their mean values.
4)
qui logit y_bin x1 x2 x3 i.opinion
margins opinion, atmeans post
The probability of y_bin= 1 is:
87% among those who “strongly agree”
51% among those who “agree”
90% among those who “disagree”
93% among those who “strongly disagree”
marginsplot
Risk management in banking - University of Rome 3
5)
tab opinion
tab country
qui logit y_bin x1 x2 x3 i.opinion i.country
margins opinion#country, post
The probability of y_bin= 1 is:
87% among those who “strongly agree” in country A
22% among those who “strongly agree”, in country B
etc.
Marginal effects
Marginal effects gives you the change in probability when the predictor or independent variable
increases by one unit.
qui logit y_bin x1 x2 x3 i.opinion
margins, dydx(*) atmeans post
The change in probability when opinion moves from ‘strongly agree’ to ‘agree’ decreases 36
percentage points or -0.36, and is significant.
The change in probability when opinion moves from ‘strongly agree’ to ‘disagree’ increases by 3
percentage points or 0.03.
The change in probability when opinion moves from ‘strongly agree’ to ‘strongly disagree’ increases by
5 percentage points or 0.05.
The change in probability for one instant change in x1 is: 13 percentage points, in x2 is 3 percentage
points and in x3 is 4 percentage points.
EXERCISE #2
By using the dataset last_class.dta, write on your do file the commands to perform the following
analysis:
1) Show the number of observations per value of the variable country, as well as the percentage
shares and cumulative shares
2) Generate an individual member identifier (by country)
3) Generate the number of individuals by country
4) Generate a personal identifier
5) Browse only the three new variables that you have just created
6) Move the three new variables at the beginning of the dataset (before the variable country)
7) Check whether x1 and x2 are correlated
8) List all saved results
Risk management in banking - University of Rome 3
9)
10)
11)
12)
13)
14)
Generate the mean of x1
Test whether the mean of x1 is equal to 20
Perform a OLS regression (y is the dependent variable)
Change the confidence interval at 99
Perform a OLS regression (y is the dependent variable) by excluding year 1999
Perform a logit regression where y_bin is the dep var and x1, x2, x3, opinion are the independent
variable. Then show the change in probability when opinion moves from ‘strongly agree’ to ‘agree’
References of Lectures 1-2-3-4-5
“OLS
Regression
Using
Stata
–
A
Very
Basic
Introduction”,
available
at:
https://www.nuffield.ox.ac.uk/teaching/economics/bond/OLS%20Regression%20Using%20Stata.pdf
(last access: December 16, 2016)
“Predicted probabilities and marginal effects after (ordered) logit/probit using margins in Stata”, by
Oscar Torres-Reyna, available at: http://www.princeton.edu/~otorres/Margins.pdf (last access:
December 16, 2016)
“Regression with Stata Chapter 1 - Simple and Multiple Regression”, available at:
http://www.ats.ucla.edu/stat/stata/webbooks/reg/chapter1/statareg1.htm (last access: December 16,
2016)
“Stata Annotated Output Descriptive statistics using the summarize command”, availabe at:
http://www.ats.ucla.edu/stat/stata/output/stata_summ_output.htm (last access: December 16, 2016)
“Stata Tutorial”, by Germán Rodríguez, available at: http://data.princeton.edu/stata/ (last access:
December 16, 2016)
“Stata Web Books Regression with Stata Chapter 2 - Regression Diagnostics”, available at:
http://www.ats.ucla.edu/stat/stata/webbooks/reg/chapter2/statareg2.htm (last access: December 16,
2016)
Stata’s help file and PDF documentation
“Statistical Computing Workshop Introduction to Stata Programming”, available at:
http://www.ats.ucla.edu/stat/stata/seminars/stata_programming/ (last access: December 16, 2016)
“Using Stata 9 & Higher for OLS Regression”, by Richard Williams, available
http://www3.nd.edu/~rwilliam/stats1/OLS-Stata9.pdf (last access: December 16, 2016)
at: