Professional Documents
Culture Documents
Matrix Application
Matrix Application
Matrix Application
Input-Output Table
• IOT for the year 1968-69 was published with 60 sectors and subsequently the tables
consisted of 115 sectors since 1973-74 till 1998-99. The IOTs for 2003-04 and the current
one (2007-08) contain 130 sectors.
• Basic Structure of IOT: A matrix of the inter-industry transaction for an economy, which
shows how the output from one sector may become an input to another industrial sector.
The economy is presented such that each industry listed across the top represents the
consuming sector (‘j’) and down the table, each row represents the producing sectors (‘i’).
• Output/ transactions of goods and services are broken down by intermediate and final use.
Intermediate use + final use = Total output
Introduction
Operations
R is case sensitive so A and a denote distinct objects.
To create a vector x, x <__ c(x1,x2, ……..xp)
To create a matrix A, A <__ matrix(data, nrow=m, ncol=n, byrow=F)
To access an individual element in a matrix A, the (i, j)th, A[i, j]
To access an individual row in a matrix A, the ith, A[i,]
To access an individual column in a matrix A, the jth, A[,j]
To access a subset of rows in a matrix A, A[i1 : i2; ]
To access a subset of columns in a matrix A, A[;j1 : j2]
To access a sub-matrix of A, A[i1 : i2; j1 : j2]
Addition A+B, A+B
Subtraction A-B, A-B
Multiplication AB, A%*%B
Transpose AT, t(A)
Inversion A-1, solve(A)
Summary of Matrix Operators in RStudio (1/2)
Operations
Determinant, det(A)
Trace of a matrix A, sum(diag(A))
To extract a diagonal of a matrix A as a vector, diag(A)
To find the dimensions of a matrix A, dim(A)
To join matrices A and B together side by side, cbind(A,B)
To stack A and B together on top of each other, rbind(A,B)
To change a dataframe into a matrix, data.matrix(dataframe)
To change some other object into a matrix, as.matrix(object)
To control the number of digits printed to 3 options(digits=3)
Prompt command ‘>’. What happened when ‘+’ appears after ‘>’?
<- and = refers to equal sign. Left hand of <- is user defined variable/s.
Functions used in IOT
Functions Description
options(scipen=999) Disable/remove scientific notation (e values)
as.matrix Converting the object into a matrix
is.na()<-0 Converting NA values to 0
as.numeric Converting the object into a numerical value
sum() Find the sum of the values
rownames() Define the row names
colnames() Define the column names
/ Divide
options() Controls the number of digits to print when printing numeric values.