Business Application IT Lab
IT BA lab Assignment #2
Session 2:
Today we have learnt about creation,inverse,transpose and multiplication of matrices.Then we moved on to
regression and residual analysis by taking NSE historical data for NIFTY index for a certain period.Finally we had an introductory idea about how to plot normally distributed curve.
Assignment 1:
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 .
Solution:
To create a matrix:
x <- c[1:9]
dim(x) <- c(3,3)
y <- c[10:18]
dim(y) <- c(3,3)
To select a column
z1 <- x[ ,3]
z2 <- y[ ,2]
z3<- cbind(z1,z2)
Output:
Assignment 3:
Read historical data of NIFTY indices from NSE for the period 1st Dec 2012 to 31st Dec 2012. Find regression and residuals
Solution:
To read the csv file:
nse <- read.csv(file.choose(),header=T)
For finding the regression and residuals the following commands are used
reg <- lm(High ~ Open , data = nse)
residuals(reg)
Output:




No comments:
Post a Comment