Tuesday, 15 January 2013

Business Application Lab - Session 2

15th Jan,2013
Assignment 1 -:
To bind columns/rows from 2 different matrices into a new matrix

Sol -:
Matrix 1 assignment and generation


> mat1<-c(1:10)
> dim(mat1)<-c(2,5)


Matrix 2 assignment and generation


> mat2<-c(11:16)
> dim(mat2)<-c(2,3)

Taking 3 column from matrix1 and 2nd column from matrix 2
Binding using the cbind and rbind functions as shown -:




Assignment 2
Multiply 2 matrices 

Sol -:
Command to multiply 2 matrices
> multip <- z1 %*% z2




Assignment 3-:
To read NSE historical data dated from 1st Dec, 2012 to 31st Dec, 2012 from a .csv file.
To find regression between the High Price and the opening share price and also calculating the residuals.

Soln- :
Command For Regression :
> reg1<-lm(HighPrice ~ OpenPrice , data = NSEData)

NSEData - Object with file historical data
High Price - Dependent variable
Open Price - Independent variable



Residuals





Assignment 4
To generate data for a normal distribution and plot the distribution curve


Soln -:
To generate normally distributed random numbers function used is -:

rnorm(N, mean,sd)
where N is the no of observations
mean is the mean vector
sd - standard deviation

As shown below -:


The plot is as shown -:









No comments:

Post a Comment