ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

R programing Question

by | Nov 29, 2023 | questions

Multiple Linear Regression – # we use mtcars dataset
require(MASS)
dat = mtcars[,c(1,3:7)]
attach(dat)

plot(dat, pch=16)

# correlation plot
require(ellipse)
plotcorr(cor(dat))

# let’s fit a simple linear model via least-square

Document Preview:

# we use mtcars dataset
require(MASS)
dat = mtcars[,c(1,3:7)]
attach(dat)

plot(dat, pch=16)

# correlation plot
require(ellipse)
plotcorr(cor(dat))

# let’s fit a simple linear model via least-squares
fit = lm(mpg ~ ., data = dat)
summary(fit)

# CIs for the coefficients
confint(fit)
# (note that the _combined_ level is _not_ 95%)

# 95% confidence interval for the mean response at a given predictor vector
new = data.frame(disp=200, hp=120, drat=3.5, wt=3.1, qsec=18)
predict(fit, new, interval=’confidence’)

# Explaining the (adjusted) R-squared
fit0 = lm(mpg ~ disp)
par(mfrow=c(1,2))
plot(disp, mpg)
abline(fit0)
boxplot(mpg-mean(mpg), residuals(fit0), names=c(‘mpg (centered)’, ‘residuals’))

# comparing models with ANOVA
fit0 = lm(mpg ~ disp + wt) # a model with only disp and wt, implicitly assuming that the other variables are not in the model
anova(fit0, fit) # ANOVA F-test comparing this simpler model with the model above that includes all 6 predictor variables

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!