SOCY401- Introduction to margins & marginsplot in Stata
5.9 هزار بار بازدید -
4 سال پیش
-
This short video shows you
This short video shows you how to 1) estimate a bivariate regression model, 2) produce predicted values, & 3) visualize the model.
This short video shows you how to 1) estimate a bivariate regression model, 2) produce predicted values, & 3) visualize the model.
Stata Code
/*
Stata help using themargins command
Uses the GSS data
*/
/* Create a subset of the GSS data */
keep year realrinc educ
drop if educ LT 8 /* Youtube does not allow using the less than symbol. Stata requires it */
keep if year==2018
drop year
keep if !missing(realrinc, educ)
/* Estimate a model of the relationship between income & education */
regress realrinc educ /* Estimate a model */
display -25386.6 + 3543.642*12 /* Calculate Y-hat for educ=12) */
/* Calculate predicted values */
predict yhat, xb
summarize yhat if educ==12
/* Usemargins to calculate the predicted values */
margins, at(educ=12)
margins, at(educ=(12 14 16))
margins,at(educ=(8(1)20))
/* Visualize the model */
marginsplot, recast(line) noci scheme(s2mono)
This short video shows you how to 1) estimate a bivariate regression model, 2) produce predicted values, & 3) visualize the model.
Stata Code
/*
Stata help using the
Uses the GSS data
*/
/* Create a subset of the GSS data */
keep year realrinc educ
drop if educ LT 8 /* Youtube does not allow using the less than symbol. Stata requires it */
keep if year==2018
drop year
keep if !missing(realrinc, educ)
/* Estimate a model of the relationship between income & education */
regress realrinc educ /* Estimate a model */
display -25386.6 + 3543.642*12 /* Calculate Y-hat for educ=12) */
/* Calculate predicted values */
predict yhat, xb
summarize yhat if educ==12
/* Use
margins, at(educ=12)
margins, at(educ=(12 14 16))
margins,at(educ=(8(1)20))
/* Visualize the model */
marginsplot, recast(line) noci scheme(s2mono)
4 سال پیش
در تاریخ 1399/01/18 منتشر شده
است.
5,973
بـار بازدید شده