Purpose-
The class focused on using regression analysis on a Data Set. The user needs to identify whether a linear model can at all be fitted, thus performing a check on non-linearity. Importance of QQ plot is also showed from the point of view of finding the range of the independent variable in which the regression analysis can be done.
Assignment 1: Using mileage groove data, fit 'lm' and comment on the applicability of 'lm'.
>reg1<-lm(Data[,2]~Data[,1])
>res<-resid(reg1)
>res
>plot(Data[,1],res)
Now plotting the Standard deviation of the residuals vs the independent variable
>stdres<-rstandard(reg1)
>stdres
>plot(data[,1],stdres)
>qqnorm(stdres)
>qqline(stdres)
Assignment 3: Hypothesis testing using Anova
>Data<-read.csv(file.choose( ), header=T)
>Data
>Data.anova<-aov(Data[,2]~Data[,1])
>summary(Data.anova)
The P value comes out to be as 0.687 which is greater than 0.05 so we do not have sufficient proof to negate the null hypothesis.
The class focused on using regression analysis on a Data Set. The user needs to identify whether a linear model can at all be fitted, thus performing a check on non-linearity. Importance of QQ plot is also showed from the point of view of finding the range of the independent variable in which the regression analysis can be done.
Assignment 1: Using mileage groove data, fit 'lm' and comment on the applicability of 'lm'.
>Data<-read.csv(file.choose,header=T)
>Data
>z1<-Data[,1]
>z2<-Data[,2]
>reg1<-lm(z1~z2)
>reg1
For normal distribution pattern...
>res<-resid(reg1)
>res
Plotting the residues vs the independent variable
>plot(z2,res)
Now the QQ plot
> qqnorm(res)
> qqline(res)
Verdict: As the plot of the residuals versus the independent variable shows a parabolic plot so we cannot draw a regression on the data set. The function over here is non-linear.
Assignment 2: The alpha-pluto Data
>Data<-read.csv(file.choose( ), header=T)
>Data>reg1<-lm(Data[,2]~Data[,1])
>res<-resid(reg1)
>res
>plot(Data[,1],res)
Now plotting the Standard deviation of the residuals vs the independent variable
>stdres<-rstandard(reg1)
>stdres
>plot(data[,1],stdres)
>qqnorm(stdres)
>qqline(stdres)
Assignment 3: Hypothesis testing using Anova
>Data<-read.csv(file.choose( ), header=T)
>Data
>Data.anova<-aov(Data[,2]~Data[,1])
>summary(Data.anova)
The P value comes out to be as 0.687 which is greater than 0.05 so we do not have sufficient proof to negate the null hypothesis.
No comments:
Post a Comment