RDataRegression

# RDataRegression - R Regression Analysis Xinhui Zhang 2013...

• 30

This preview shows pages 1–5. Sign up to view the full content.

R Regression Analysis Xinhui Zhang 2013 Edelman Laureate Professor Wright State University October 2, 2016 A majority of the materials are taken from the following book: ”An Introduction to Statistical Learning with Applications in R” by Gareth James, Daniela Witten, Trevor Hastie and Robert Tibshirani. The book can be downloaded at ~ gareth/ISL/index.html To start, we clean the R workspace and release any memory not in use. ################################################################################ # Clean the objects in the enviroment and gabarage collection of memory ################################################################################ rm ( list = ls ()) gc () ## used (Mb) gc trigger (Mb) max used (Mb) ## Ncells 303249 16.2 592000 31.7 369318 19.8 ## Vcells 514313 4.0 1023718 7.9 786425 6.0 1 Linear Regression linear regression is a very simple approach for supervised learning. In particular, linear regression is a useful tool for predicting a quantitative response. The data used in the illustraction is an advertising data which displays sales (in thousands of units) for a particular product as a function of advertising budgets (in thousands of dollars) for TV, radio,and newspapermedia. 1

This preview has intentionally blurred sections. Sign up to view the full version.

## ## Residuals: ## Min 1Q Median 3Q Max ## -8.3860 -1.9545 -0.1913 2.0671 7.2124 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 7.032594 0.457843 15.36 <2e-16 *** ## TV 0.047537 0.002691 17.67 <2e-16 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 3.259 on 198 degrees of freedom ## Multiple R-squared: 0.6119,Adjusted R-squared: 0.6099 ## F-statistic: 312.1 on 1 and 198 DF, p-value: < 2.2e-16 plot (TV, Sales ); abline (salesLM, col = "red" ) 0 50 100 150 200 250 300 5 10 15 20 25 TV Sales 3

This preview has intentionally blurred sections. Sign up to view the full version.

1.2 Parameter Results and Residuals: The parameters estimated are obtained through the lm are β 0 = 7 . 03 and β 1 = 0 . 047. In other words, according to this approximation, an additional \$1,000 spent on TV advertising is associated with selling approximately 47.5 additional units of the product.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern