report | assignment | stata代写 | 经济代写 | econ代写 – Stata Assignment 1 Econ 120B Spring 2022

Stata Assignment 1

report | assignment | stata代写 | 经济代写 | econ代写 – 本题是一个利用econ120b进行练习的代做, 对econ的流程进行训练解析, 涵盖了econ等程序代做方面, 这个项目是assignment代写的代写题目

ass代做 assignment代写 代写assignment

Econ 120B Spring 2022 
Department of Economics, UCSD
  • You shouldsubmit your answers on Canvas, including your do-file.
  • The deadline of submitting this Stata assignment isApril 22, 11:59pm. No late submission will be accepted.
  • This Stata Assignment will be graded on three scales: 0%, 5%, and 10%. (For example, if you are able to answer more than half of the questions correctly, your will get the full credit for this assignment.)
  • If your do-file does not run, we will subtract 2.5%.
  • Name your do-file with your PID, such as A12345678.do. Start your do-file with the following (also include your name and PID in your do-file)
/*******************************************************************************
ECON 120B, Spring 2022
Stata Assignment 1
Name:
PID:
*******************************************************************************/
clear all // clear the environment/memory
set more off
sysuse nlsw88 // load the built-in dataset nlsw
Please make sure your do-file is reasonably documented to help us understand your code.
  • nlsw88is a built-in dataset that comes with Stata. It is an extract from the 1988 round of the National Longitudinal Survey of Mature and Young Women. Following is a summary of the variables in this dataset.
idcode survey id
age age
race race, can take three values,white,blackorother
married = 1 if is currently married, = 0 otherwise
nevermarried = 1 if never married, = 0 otherwise
grade current grade completed
collgrad = 1 if graduated from college, = 0 otherwise
south = 1 if lives in southern states, = 0 otherwise
smsa = 1 if lives in standard metropolitan statistical area, = 0 otherwise
ccity = 1 if lives in central city, = 0 otherwise
industry industry, usetab industryto see the categories
occupation occupation, usetab occupationto see the categories
union = 1 if is in a union, = 0 otherwise
wage hourly wage, measured in $
hours hours worked per week
ttlexp total work experience, measured in years
tenure current job tenure, measured in years
More information on the original data can be found here:
https://www.bls.gov/nls/orginal-cohorts/mature-and-young-women.htm
  1. In this exercise you will re-label variables and create some new variables which will be used later.
(a) Re-label the variablesmsatolive in urban areasso that it is more informative. Note that SMSA stands for
standard metropolitan statistical area.
(b) Re-name the variablesmsatourban.
(c) Generate a new variable calledwagecopytaking the same values as the variablewage, so that we can modify the
wage data without loosing the original variable.
(d) The minimum wage in 1988 was $3.35 an hour. Lets say our fictional bosses at the Bureau of Labor Statistics
will be mad if they see evidence of minimum wage law violations in the dataset. Inwagecopy, replacewagecopy
with 0 for workers that earned strictly less than $3.35 an hour.
(e) How many observations are in this dataset?
(f) How many missing observations are inwagecopy?
(g) Generate a variable calledlnwagecopywhich is the natural logarithm ofwagecopy.
(h) How many missing observations are inlnwagecopy? Why does this make sense?
  1. In this exercise, you are asked to compute some simple summary statistics using the binary variablecollgrad, contained in the dataset.
(a) Use the commandtabulateto show the two categories of the variablecollgradand their frequencies. What is
the proportion of the categorynot college grad? Please  report a number between 0 and 1.
(b) Use the same command, this time specifying the optionnolabel, to visualize the numeric values corresponding
to the different categories ofcollgrad. Which numeric value corresponds to the labelcollege grad?
(c) Use the commandsummarizeto compute the sample mean ofcollgrad. After executingsummarize, Stata stores
temporarily the sample mean in the objectr(mean). To see this, generate a scalar variablecollgradmeanequal
tor(mean), by typingscalar collgrad mean = r(mean)in the line just after the commandsummarize. Finally,
display the variable value by typingdisplay collgradmean, and verify that the value displayed is the same as
the one returned by the commandsummarize. What is the sample mean ofcollgrad? What is its relation to
your answer in 2(a)?
(d) Repeat the steps of 2(c), this time to create a scalar variable,collgradvar, containing the sample variance of
collgrad. What is the sample variance ofcollgrad? (Hint: after running thesummarizecommand, you can find
the sample variance byr(Var)).
(e) Compute the sample variance ofcollgradwithout thesummarizecommand, using only the variablecollgradmean.
(Hint: you can think ofcollgradas drawn from a Bernoulli distribution with parameterp, wherepis the prob-
ability of having a college degree. The (population) variance of a Bernoulli random variable isp(1p). What is
the relation betweenpand the sample meancollgradmean? Finally, remember that the sample variance can be
obtained starting from the formula of the population variance by replacing the population mean with the sample
mean.)
  1. The following problems provide more practice using conditional statements to tabulate and summarize variables.
(a) Among unmarried people, what is the fraction of those who were married before? You should report a number
between 0 and 1. (Hint: use the variables,marriedandnever married.)
(b) What is the difference in average hours worked for married and unmarried workers? Please report a positive
number. (Hint: use the variablesmarriedandhours.)
(c) What is the average hours worked for unmarried college graduates with strictly more than 8 years of experience?
(Hint: use the variablesmarried,collgrad,ttlexp, andhours.)
(d) Among those living in urban areas, what is the fraction of laborers? Please report a number between 0 and
  1. (Hint: use the variablesoccupationandurban. In addition, missing values should not be counted in your calculation.)
(e) Use the variablewagecopy. Among unionized workers, what is the fraction of those who earn strictly more than
$6.5 an hour? Please report a number between 0 and 1.
  1. This exercise refers to the following model:
wagei= 0 + 1 gradei+ui,
where the wage of individualiis regressed on his/her highest grade completed and a constant term. You are asked to
compute the intercept and slope estimates in a variety of ways, and compare your results in each case. First, use the
command
keep if !missing(wage, grade)
to drop people with missingwageorgradefrom the dataset.
(a) How many observations were dropped?
(b) Use theregresscommand to estimate the coefficients 0 and 1. What is the value of 0? What is the value of
 1? (Hint: typeregress wage grade, the constant term will be added automatically to the regression. To find
 0 , check the row labeled by consand the column labeled byCoef.)
(c) You are now asked to compute the same estimates using a different procedure:
  • Compute the sample covariance betweenwageandgrade, and the sample variance ofgrade, and save them in two scalars,covwgandvarg. (Hint: you can compute the variance-covariance matrix using thecorr command, with the optioncovariance. For instance, if you typecorr wage grade, covariance, the output will be a matrix containing the variance ofwage, the variance ofgradeand the covariance betweenwageand grade.
On a related note, the three values will be stored inr(Var1),r(Var2)andr(cov 12), respectively. You
can check the list of stored objects by typingreturn listjust after running thecorrcommand.)
  • Generate the scalarbeta 1 equal tocovwg / vargand display it by typingdisplay beta 1. What is the relation between this estimate for 1 and the one in 4(b)?