Please conduct and document all of your work using a Stata .do ("DO-file) file. You can open a new .do file with Ctrl-9 on a PC and CMD-N on a Mac.
Please email your assignment to the IR602 e-mail account at ir602.2021@gmail.com. You do not need to submit any additional write-up, unless you would like further feedback.
a. Open Stata, and generate a data set with 100 observations containing the following variables:
1. height_mother: a random variable with mean 165 cm and standard deviation 10 cm.
2. noise: a normal random variable with mean 5 cm and standard deviation 10 cm.
Remember to set the seed of the dataset before generating the variables above. Set the seed of the dataset to 6023.
Give proper labels to each of the variables. Summarize the variables (provide the mean, standard deviation, minimum, and maximum for each variable), and generate histograms for each of the variables.
b. Generate the height of the child (variable “child height”), βπ , variable which is given by the true relationship defined below:
ππ = 10 + 0.5 ⋅ ππ + ππ
where βπ is the height of the mother and ππ is the noise term. Summarize this new variable and generate the histogram to show the distribution of child height. What is the mean child height that you obtain?
c. The scatter command in Stata is used to generate a scatter plot for a set of data points in Stata, and the lfit command in Stata can be used to plot the line of best fit for the set of points. These two commands can be combined into a single command on the same graph as follows:
graph twoway (scatter y x)(lfit y x)
where y is the dependent variable and x is the independent variable.
Use the combined graph command above to generate a scatter plot of maternal height on the x-axis and child height on the y-axis and the line of best fit for the data.
d. We will now estimate the slope of the line of best fit that you have drawn in part c, denoted π½-1:
The egen command in Stata is very useful for generating special functions and extensions of variables that go beyond just the standard gen command. One of the functions that we can use with the egen command is the mean function, which is as follows:
egen y = mean(x)
which generates a new variable y that takes on the average of all of the individual π values in the variable x, i.e.
π¦ = π₯Μ = 1
π
π
5 π₯6
681
a. Use the egen and mean syntax above to generate :β:π:: and :β::π, which are variables of the mean of the mother’s height and child’s height, respectively.
b. Use the gen command to generate a variable that takes the difference of each individual mother’s height :β:π:::,= and β::π::,=, i.e. βπ,6 - :β::π:.
c. Use the gen command to generate a variable that takes the difference of each individual child’s height, βπ,6 and :β::π, i.e. βπ,6 - β:::π.
d. Use the gen command to generate a variable that is the square of βπ,6 - β:::π: from (ii),
i.e. (βπ,6 − β:::π:)A.
e. Use the gen command to generate a variable that is the product of βπ,6 - β:::π: from (ii),
and βπ,6 - :β::π from (iii), i.e. (βπ,6 −:β::π) (βπ,6 − :β::π:).
Another function that we can use with the egen command is the sum function, as follows:
egen y = sum(x)
which generates a new variable y that is the sum of all of the values in the variable x, i.e.
π
π¦ = 5 π₯6
681
f. Using the egen and sum commands in Stata, generate the sum of the (βπ,6 −
variable from (iv), i.e.
:β::π:)A1BB
5(βπ,6 −681 :β::π:)A
g. Using the egen and sum commands in Stata, generate the sum of the
(βπ,6 −:β::π) (βπ,6 − :β:π::) variable from (v), i.e. 1BB
5(βπ,6 − :β::π)(βπ,6 −681 :β::π:)
h. Generate the variable π½-1, which is the ratio of (vii) and (vi) as follows:
π½-1 =
∑1BB(βπ,6 − :β::π)(βπ,6 − :β::π:)
∑1BB(βπ,6 − :β::π:)A
e. Summarize the variable π½-1, which is your estimate for the slope of the line that you drew in part c. What is its mean? How does your mean compare to the true value of the relationship between mother’s height and child height from part b. above?
f. We will now estimate the intercept of the line of best fit that you have drawn in part c, denoted πE. Using the variables that you have generated in the previous sections, generate πE as follows:
πE = :β::π − π½-1 β
:β::π:
Summarize the variable πE, which is your estimate for the intercept of the line that you drew in part c. What is its mean? How does this estimate of πE compare with the true value of the constant in the relationship from part b. above?
g. The Stata command reg runs the OLS regression of variable y on variable x as follows:
reg y x
Run the OLS regression of child height βπ on maternal height βπ. What is the value of the coefficient that you obtain on maternal height? What is the value of the constant? How do these values compare to the estimates of the slope and intercept that you calculated in parts e. and f. above?
h. Provide an interpretation for this estimate π½-1.
i. Provide an interpretation for the estimated constant πE.
A researcher is interested in estimating the effect that the number of cups of coffee that a pregnant mother drinks has on her baby’s health. A common measure of a child’s health and birth is her weight. The researcher decides to estimate the following regression:
π6 = π + π½πΆ6 + π6
where:
π6 : the weight at birth of mother i’s baby (in ounces)
πΆ6: the daily number of cups of coffee drunk by mother i during the pregnancy π6: the error term
a. Would you expect the estimate of π to be positive or negative? What does π represent?
b. Would you expect the estimate of π½ to be positive or negative? What does π½ represent?
c. Give an interpretation of π6. Give examples of 3 factors that may end up in π6.
d. Suppose the following estimates are obtained from a sample of 1,388 births:
πJ6 = 119.77 − 0.514πΆ6
To obtain a predicted birth weight of 125 ounces, what would πΆ6 have to be? Is this value of πΆ6 sensible? Why or why not?
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme