library(openxlsx) dat<-read.xlsx("http://kanggc.iptime.org/book/data/macro-country-e.xlsx") A<-as.matrix(dat) H<-matrix(c(0,0,350,450,1200,600,450,280,0,0,0,0), nrow=12) H X<-t(solve(A)%*%H) XV<-as.vector(X) names(XV)<-c("Y1=","Y2=","C1=","C2=","I1=","I2=","G1=","G2=","M1=","M2=","X1=","X2=") XV IH<-matrix(c(0,0,350,450,1200,600,550,280,0,0,0,0), nrow=12) IX<-t(solve(A)%*%IH) IXV<-as.vector(IX) names(IXV)<-c("Y1=","Y2=","C1=","C2=","I1=","I2=","G1=","G2=","M1=","M2=","X1=","X2=") IXV I1Y1M<-(IXV[1]-XV[1])/(IH[7]-H[7,1]) names(I1Y1M)<-c("dY1/dG1=") I1Y1M I1Y2M<-(IXV[2]-XV[2])/(IH[7]-H[7,1]) names(I1Y2M)<-c("dY2/dG1=") I1Y2M