Linear Regression and Correlation Analysis Assignment

Added on - 29 Apr 2020

  • 13

    pages

  • 1372

    words

  • 1

    views

  • 0

    downloads

Showing pages 1 to 4 of 13 pages
ASSIGNMENTLinear Regression and Correlation Analysis in RNAME:COURSE:ADMISSION:Question OneLoad data#loading the data in R script window>y=c(5.39,5.73,6.18,6.42,6.77,7.11,7.46,7.71,8.15,8.5)>x=c(4,5,6,7,8,9,10,11,12,13)>dat=cbind(x,y)>dat=as.data.frame(datCalculate the linear regression (Distance is predictor variable, Number isresponse variable)
>#regression modelling>fit<-lm(y~x)#output of the model>fitCall:lm(formula = y ~ x)Coefficients:(Intercept) x4.0551 0.3396The equation of the line Y=4.0551+0.3396x> #obtaining summary of of statistics> summary(fit)Call:lm(formula = y ~ x)Residuals:Min 1Q Median 3Q Max-0.08109 -0.02059 -0.00200 0.01659 0.08709Coefficients:Estimate Std. Error t value Pr(>|t|)(Intercept) 4.055091 0.045198 89.72 2.66e-13 ***x 0.339636 0.005038 67.42 2.61e-12 ***
---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1Residual standard error: 0.04576 on 8 degrees of freedomMultiple R-squared: 0.9982, Adjusted R-squared: 0.998F-statistic: 4545 on 1 and 8 DF, p-value: 2.607e-12The null hypothesis is predictor variable (x) is not significance in the model. The p-valueis 2.607e-12 which is less than the level of significance 0.05 therefore we reject the nullhypothesis and conclude that the predictor variable (x) is significance in the model. It canbe used to predict response variable (y).The R-squared is 0.9982 which means 99.82% of the variation in y are explained by xthus the model is good fitPlot the best fit line on a scatterplot of the data>#ploting the scatterplot>plot(x,y, abline(fit), main="Scatter plot")
46810125.56.06.57.07.58.08.5Scatter plotxyThe relation between x and y is positive linear. Only few points which lies outside the line ofbest fit.Plot the residual charts> #split the plotting panel into 2 times 2 grid> par(mfrow=c(2,2))> #residuals plotting> plot(fit)
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document