Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Practice Problem set #6 Computer Applications Instructions: Please print out all

ID: 663853 • Letter: P

Question

Practice Problem set #6 Computer Applications Instructions:

Please print out all the commands you used, as well as the results. Only the material discussed in the lecture on regression in matrix form and the lecture on using the software will be needed.

Problem1 Use the R language (or any other software) to perform the following analyses: Use the data contained in the excel file dataFE.xlsx to answer the following questions.

i)

Use the built in R function “lm” with appropriate arguments to run a regression of y on x1, x2, x3, x1^2, x2^2, x1x2.

ii)

State which coefficients are statistically significant. Use the summary function.

iii)

Is the regression as a whole significant?

iv)

Do you notice any correlation between some of the explanatory variables, especially when considering t and F tests? Explain.

v)

Again using the summary function, write down the fitted model.

vi)

State the Sum of Squares of Residuals. [hint: the summary--?output gives the residual standard error. Use it to obtain SSR.]

Problem #2

Use R (or any other software) to calculate the following, using the data from the excel file dataFE.xlsx.

i) State the data matrix X (regression of y on x1 and x2) and print its first few rows with the command “head()”, which requires the data matrix as the argument.

ii) Obtain OLS estimates of the regression of y on x1 and x2 without using the buil in R--?functions,but using the matrix formulas from Appendix E.

iii)

Calculate the estimated covariance matrix of the coefficient vector using again the formulas from appendix E.[hint: you need the estimated error variance, “sigma_hat_squared”. You may use the lm and summary functions to obtain this variance.]

Explanation / Answer

# All Subsets Regression
library(leaps)
attach(mydata)
leaps<-regsubsets(y~x1+x2+x3+x4,data=mydata,nbest=10)
# view results
summary(leaps)
# plot a table of models showing variables in each model.
# models are ordered by the selection statistic.
plot(leaps,scale="r2")
# plot statistic by subset size
library(car)
subsets(leaps, statistic="rsq")

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote