For econometrics
Page 1
Overview of Data Analysis Questions
Variables to Analyze:
bwght(birth weight),educ(education),unmarried(marital status)Statistical Metrics:
Average
Standard Deviation
Minimum Value
Maximum Value
Data Visualization: Histogram for child birth weight
Comment on the distribution
Observations: Total number of observations in the dataset
Results for Birth Weight, Education, and Marital Status
1. Analyzing Variables
(a) Calculate metrics for:
bwght: Find average, standard deviation, min, max valueseduc: Find average, standard deviation, min, max valuesunmarried: Similar metrics
(b) Generate a histogram of
bwghtComment on the distribution shape (normal, skewed, etc.)
(c) Count and report total number of observations
2. Unmarried Mothers and Prenatal Visits
(a):
Percentage of mothers who are unmarried
Average number of prenatal visits for unmarried mothers
(b) Create a new variable
agegroup:Value 1: <20 years,
Value 2: 20-29 years
Value 3: 30-39 years
Value 4: ≥40 years
Count mothers aged 30+
2. (a) What percentage of mothers are unmarried? What is the average number of prenatalvisits to a doctor by an unmarried mother?
table(mpgdrv) / nrow(mpg)(b) Generate a new variable, agegroup, which takes value 1 if the mother is youngerthan 20 years, value 2 for age group 20-29 years, 3 for age group 30-39 years, and 4for age group 40 years and older. How many mothers are there aged 30 years and older?3. (a) Examine graphically the relationship between
3. Age and Marital Status Relationship
(a) Graph the relationship using a bar graph
Show fractions of unmarried mothers in each age category
Comment on the observed trends
(b) Calculate correlation coefficient between age and marital status
Discuss the strength of the relationship
4. Linear Regression on Birth Weight
(a) Fit a linear regression of
bwghton age and education of motherReport results including coefficients, R², etc.
(b) Effect of changing education from 12 to 16 years on
bwghtprediction(c) Effect of changing age from 22 to 27 years on
bwghtprediction
5. Logarithm of Birth Weight Regression
(a) Create
lbwght, which is the natural logarithm ofbwght(b) Fit a regression of
lbwghton age and educationReport results
(c) Predict effect of education change on
lbwght(d) Test significance of mother’s age at 10% significance level
Page 2
Variable Transformation and Regression Analysis
6. Age-Squared Variable and Regression Model
(a) Create
agesq, the square of age, and fit a regression ofbwghtInclude age, education,
agesqReport results
(b) Test joint significance of age and
agesqcoefficients at 5% level(c) Determine
agesqvalue for maximizing predicted birth weight
7. Full Regression Model including Prenatal Visits
(a) Fit regression of
bwghton age, education, andnprevist(number of prenatal visits)Report results
(b) Interpret coefficient of
nprevistTest significance of education on
bwghtat 10% level
(c) Compare R² before and after including
nprevist(d) Calculate residuals from regression in 7a; obtain sample mean and standard deviation
8. Regression Results for Different Categories
(a) Fit model of
bwghton age, education,nprevist, andsmokerReport results
(b) Fit the same model for mothers aged 30+
(c) Fit for mothers aged <30
(d) Conduct Chow test for homoskedasticity across age groups
9. Summary of Regression Results
(a) Create a table summarizing estimates and standard errors from all models
Include all relevant metrics (coefficients, standar
3. (a) Examine graphically the relationship between age and marital status, using a bar graph. In this graph, each bar should show the fraction of mothers who are unmarried during pregnancy for one of the age categories defined in question 2b. Comment on your result.
barplot(table(mpg$drv))barplot(hwy ~ drv, data = mpg,
xlab = "Drivetrain (f = FWD, r = RWD, 4 = 4WD)",
ylab = "Miles Per Gallon (Highway)",
main = "MPG (Highway) vs Drivetrain",
pch = 20,
cex = 2,
col = "darkorange",
border = "dodgerblue")(b) Calculate the correlation coefficient between age and marital status. Is there a strong relationship between these two variables?
plot(dist ~ speed, data = cars,
xlab = "Speed (in Miles Per Hour)",
ylab = "Stopping Distance (in Feet)",
main = "Stopping Distance vs Speed",
pch = 20,
cex = 2,
col = "red")cor(x,y)