logo

Linear Regression and Correlation Analysis Assignment

13 Pages1372 Words109 Views
   

Added on  2020-04-29

Linear Regression and Correlation Analysis Assignment

   Added on 2020-04-29

ShareRelated Documents
ASSIGNMENT Linear 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 is response variable)
Linear Regression and Correlation Analysis Assignment_1
>#regression modelling>fit<-lm(y~x)#output of the model>fitCall:lm(formula = y ~ x)Coefficients:(Intercept) x 4.0551 0.3396 The 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.08709 Coefficients: 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 ***
Linear Regression and Correlation Analysis Assignment_2
---Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.04576 on 8 degrees of freedomMultiple R-squared: 0.9982, Adjusted R-squared: 0.998 F-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 null hypothesis 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 x thus 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")
Linear Regression and Correlation Analysis Assignment_3
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 of best fit.Plot the residual charts> #split the plotting panel into 2 times 2 grid> par(mfrow=c(2,2))> #residuals plotting> plot(fit)
Linear Regression and Correlation Analysis Assignment_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Regression Analysis | Assignment-1
|7
|872
|19

Environmental Data Analysis - Assignment
|5
|1407
|16

Linear Modeling Question and Answer
|12
|1549
|9

R Programming Analysis 2022
|7
|1725
|21

Frequency Analysis of Regenerate Vegetative or by Seed and Cross-Classified Plant Species
|9
|1580
|251

Assignment Sample Solutions and Codes
|16
|6050
|19