Econ 3818Spring 2019R exercise 5Due Wednesday, May 1st in class. If you are unable to attend class that day, please email it to mebefore class and submit a hard copy the following class. Only hard copies will be graded.Submit R code used to answer all question as part of the document. Separate the R code aboveand below by three asterisk (***).You may work in groups of three (but no more than three!). Please put the name of all groupmembers at the top of the text file.1. For this exercise we will run a regression using Swiss demographic data from around1888. The sample is a cross-section of French speaking counties in Switzerland.This data come with the R package datasets. The first step is to load the package intoyour current environment by typing the command library(datasets) in to the R console.1This loads a number of datasets including one called swiss. Type help(swiss) in theconsole for additional details. The basic variable definitions are as follows:Use the summary() command to report the mean and median for the variables Fertility,Education, and Catholic.2. We want to estimate the expected Fertility level in a Swiss county conditional on thecounty’s education level. We assume the relationship is linear. So, we are interested inIf we use Ordinary Least Squares to estimate and we have the following formulas�Where is the left hand side variable, is the right hand side variable, the bar A denotesthe mean, is the standard deviation, and is the correlation. 1 If you encounter an error you might have to install the package onto your computer using theinstall.packages(datasets) command.a. Find the correlation between Education and Fertility using the cor() function, aswell as the sample standard deviation for each variable using the sd() function.Report these numbers and the code used.b. Use the cor() and sd() function to get an estimate for ? in the equation relatingFertility to Education. Keep this value stored in a scalar called beta_hat. Reportthis number.c. Now use the estimate beta_hat, along with the function mean() to get an est代做Econ 3818作业、代写Least Squares作业、R程序设计作业代做、代写R课程设计作业 代写R语言程序|imatefor alpha. Keep this value stored as a scalar called alpha_hat. Report this number.3. Use alpha_hat and beta_hat to predict the average fertility rate in a county where 40% ofthe population is educated.4. Plot the relationship between Fertility and Education using the plot() function withEducation on the horizontal axis. Do this using the plot() function. Make sure to labelyour axis!5. Now estimate the model the model relating Fertility Rate to Education using the lm()function in R’s base code. Typically, if you want to estimate ?B = ? + ??B + ?B you usethe syntaxlm(yvar ~ xvar, dataframe).a. Store the estimation results from estimating the model in a list called model_1.This list should include a number of details include the estimated parameters, thecoefficient of determination (r-squared), all of the residuals from the model, andmore.b. Use the command summary(model_1) to report the summary of the ordinary leastsquares estimation and paste the results in the word document. Do you have thesame estimates for and from Question 2 part b and c?c. What is the R-squared from this regression? Interpret it in a meaningful way.6. For each one of the estimated parameters reported in Question 5:a. Interpret the coefficient in a meaningful way.b. Report the results from testing the null hypothesis that the true parameter value iszero.7. Recreate the figure in Question 4, and then add the line of best fit using the abline()function with the coefficients from model_1, model_1$coefficients.8. Plot Education with the residuals associated with the model, model_1$residuals. Paste theplot in the document. Do the residuals show any pattern?9. Use the mean() command to show that the average of the residuals associated withmodel_1 is zero. Report the code used and the average of the residuals.10. Now estimate the parameters in the following model Using the summary() and lm() commands.a. Interpret the point estimate for betab. Is the estimate statistically significant?c. How does the R-squared compare to model 1 estimated in equation 5?转自:http://www.7daixie.com/2019050148150784.html
网友评论