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)





No comments:

Post a Comment