Question
For expert using R , I solve it but i need to figure out what I got is correct or wrong. Thank you
(a) What is the second degree polynomial model in terms of mnemonic variable names and its estimated regression equation? Test hypotheses for slope parameters and write a short paragraph stating your findings. Use a significance level of α-0.05. (b) (c) Complete the following analysis of variance table for this model Sum SqMean S Source df F valuePrF) Total Corrected) (d) Perform regression diagnostics and comment on the validity of each assumption. This includes four diagnostic plots and the Shapiro-Wilk test. For Shapiro-Wilk, give hypotheses, result fron use a-0.01 to make a decision about the null hypothesis, and give a conclusion (e) Make a scatterplot of the sample data and include the estimated regression curve for the second degree polynomial Comment on this gr () Compare the regression models for simple linear regression and the second degree polynomial model. Use Adjusted R and Mean Square Error (or Mean Square Residuals). Comment on the results. Which model do you recommend?
# Simple Linear Regression and Polynomial Regression
# HW 2
#

# Read data from csv file
data <- read.csv("C:\data\SweetPotatoFirmness.csv",header=TRUE, sep=",")
head(data)
str(data)

# scatterplot of independent and dependent variables
plot(data$pectin,data$firmness,xlab="Pectin, %",ylab="Firmness")

par(mfrow = c(2, 2)) # Split the plotting panel into a 2 x 2 grid

model <- lm(firmness ~ pectin , data=data)
summary(model)
anova(model)
plot(model)
shapiro.test(resid(model))
# examine histogram and boxplot of residuals
par(mfrow = c(1, 1))
hist(resid(model))
boxplot(resid(model))

# predict dependent variable for specified value of independent variable
predict(model, data.frame(pectin = 1.5))

# Estimated regression line and scatterplot of data
plot(data$pectin,data$firmness,xlab="Pectin, %", ylab="Firmness",
ylim=c(45,75),xlim=c(0,3),main="Simple Linear Regression",
pch=19,cex=1.5)
lines(sort(data$pectin),fitted(model)[order(data$pectin)], col="blue", type="l")

par(mfrow = c(2, 2))
# fit a second degree polynomial
# create quadratic term for pectin
data$pectinSq <- data$pectin^2
model2 <- lm(firmness ~ pectin + pectinSq , data=data)
summary(model2)
anova(model2)
plot(model2)
shapiro.test(resid(model2))
par(mfrow = c(1, 1))
hist(resid(model2))
boxplot(resid(model2))

# predict dependent variable for specified value of independent variable
predict(model2, data.frame(pectin = 1.5, pectinSq=2.25))

# Estimated regression line and scatterplot of data
plot(data$pectin,data$firmness,xlab="Pectin, %", ylab="Firmness",
ylim=c(45,75),xlim=c(0,3),main="Simple Linear Regression",
pch=19,cex=1.5)
lines(sort(data$pectin),fitted(model2)[order(data$pectin)], col="blue", type="l")



0 0
Add a comment Improve this question Transcribed image text
Answer #1

The code is perfectly fine here. But the conclusions are needed in each part.

Both for linear model and second degree polynomial model fitting, we should comment on our findings in the following way :

(C) The ANOVA table give the conclusions in such a way that :

If the p value <= .05, we should reject the null hypothesis at level 0.05.

And p value > .05 implies we should accept the null hypothesis at level 0.05.

(d) In Shapiro Wilks normality test, if the p value comes out to be less than or equal to 0.05 , we conclude that the errors are not from Normal distribution.

If p value > 0.05, we conclude that the errors are Normally distributed.

(e) From the scatterplot, if the data goes more or less closely to the estimated regression curve for second degree polynomial , then fitting second degree polynomial to the data will be the best option.

(f) on fitting both linear regression and second degree polynomial regression we get adjusted R square values.

The one with the greater adjusted R square value will be better to fit to the given data..

Add a comment
Know the answer?
Add Answer to:
For expert using R , I solve it but i need to figure out what I...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • actually other expert help me with a solution for hw1 (thanks a lot for him). so...

    actually other expert help me with a solution for hw1 (thanks a lot for him). so , if you look just the question that I post you can see it or just write the first line of the question , thank you for your interest in my question . I post the code that I used at first homework # Set directory to data folder setwd("C:data") # getwd() # Read data from csv file data <- read.csv("SweetPotatoFirmness.csv",header=TRUE, sep=",") head(data) str(data)...

  • Please I want someone help me to solve this question a,b,c,d,e I’m not sure about my...

    Please I want someone help me to solve this question a,b,c,d,e I’m not sure about my solution This is the data # Set directory to data folder setwd("C:data") # getwd() # Read data from csv file data <- read.csv("SweetPotatoFirmness.csv",header=TRUE, sep=",") head(data) str(data) # scatterplot of independent and dependent variables plot(data$pectin,data$firmness,xlab="Pectin, %",ylab="Firmness") par(mfrow = c(2, 2)) # Split the plotting panel into a 2 x 2 grid model <- lm(firmness ~ pectin , data=data) summary(model) plot(model) par(mfrow=c(1,1)) # Residual Plot data$residuals...

  • I am trying to plot a time series model using R. So far I have the...

    I am trying to plot a time series model using R. So far I have the following code, but I'm getting an error located at the very bottom. Can you please explain what I'm doing wrong, and what I should be doing instead in order to avoid the error? As far as the data is concerned, the first column displays time (hour-by-hour) across 20 days, giving 504 rows of data and the six columns thereafter display the bike demand/usage at...

  • **Just need help with one I got wrong** Thank you Budget Analysis I: A budget is...

    **Just need help with one I got wrong** Thank you Budget Analysis I: A budget is an expression of management's expectations and goals concerning future revenues and costs. To increase their effectiveness, many budgets are flexible, including allowances for the effect of variation in uncontrolled variables. For example, the costs and revenues of many production plants are greatly affected by the number of units produced by the plant during the budget period, and this may be beyond a plant manager's...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT