Wednesday, 23 January 2013

R Statistical tool Assignment-3

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'.

>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.





Tuesday, 15 January 2013

R-Statistical Tool Assignment -2

Second Day - Matrices operations like 1- Transpose ; 2- Inverse; 3- Merging two columns from two different matrices 4-Regression using the data from NSE;

Q1- Create two matrices of say size 3 X 3 and select the column 1 from one matrix and column 3 from second matrix. After selecting the columns in objects say x1 and x1  merge these two columns using cbind to create a new matrix 

> matrix1<-c(1:9)
> matrix2<-c(10:18)
> dim(matrix1)<-c(3,3)
> dim(matrix2)<-c(3,3)
> z1<-matrix1[,1]
> z2<-matrix2[,1]
> z<-cbind(z1,z2)
> z

Q2- Multiply two matrices 

> multipliedmatrix<-matrix1 %*% matrix2
> multipliedmatrix

Q3-Read historical data of indices from NSE for the period 1st Dec 2012 to 31st Dec 2012. Find regression and residuals

> z<-read.csv(file.choose(),header=T)
> High<-z[,3]
> open<-z[,2]
> z1<-cbind(high,low)
> reg1<-lm(high~open,data=z)
> reg1

Screenshot ......of the above three commands 










Q4- Create a normal distribution and plot it 

>x<-rnorm(50,0,1)
> y<-dnorm(x)
> plot(x,y)





Tuesday, 8 January 2013

R-statistical tool Introduction Assignment-1

Welcome to the Introduction of the "R x64 2.15.2" Data Analysis and Statistical tool

Assignment-1 
Creating a histogram from the given Data set:

 Assignment-2 
 Creating a both lines and dots graph of the S&P- CNX-Nifty High graph from October 2012 to 8th     January-2013

 
Assignment-3
 Creating a both lines and dots graph of the S&P- CNX-Nifty High and low from October 2012 to 8th January-2013

Assignment-4 
The command for finding the difference between the highest and the lowest value reached by the S&P-CNX-nifty 50 from October 2012 to 8th January 2013 

> high<-z[,3]
> low<-z[,4]
merge-data <-c(high,low)
> range(merge-data)