IT Business Application lab Assignment#2
Session 2:
Date:15th Jan,2013
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 2:
Multiply both the matrices.
Solution:
z <- x %*% y
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:
Assignment 4:
Generate a normal distribution data and plot it.
Solution:
For creating the ND following commands are used:
x<-rnorm(40,0,1)
y<-dnorm(x)
For plotting the data
plot(x,y)
Output:




No comments:
Post a Comment