library(tidyverse)
I_MAT <- read.csv("Wyoming_2024_SAM_v1.7/Wyoming_ixi_39_naics2_2024.csv")
NAMES <- I_MAT[,1]
LEN  <-  nrow(I_MAT)
I_MAT <- I_MAT[,-1]
I_MAT <- as.matrix(I_MAT,nrow=LEN)
colnames(I_MAT) <- NAMES
rownames(I_MAT) <- NAMES
TOTALS <- colSums(I_MAT )
TOTALS <- ifelse(TOTALS==0,0.000000,TOTALS) %>% as.numeric
#Column division
A_MAT <- t(t(I_MAT)/TOTALS)
ACCOUNT_RANGE <- (LEN-13):LEN
TYPE1_A <- A_MAT[-ACCOUNT_RANGE,-ACCOUNT_RANGE]
MULTIPLIER_OUTPUT_TYPE1 <- solve(diag(LEN-14)-TYPE1_A)
TYPE1_MULTIPLIERS_TOTAL <- colSums(MULTIPLIER_OUTPUT_TYPE1 )

DEMAND_RANGE <- ACCOUNT_RANGE[-1:-6]
TYPE2_A <- A_MAT[-DEMAND_RANGE,-DEMAND_RANGE]
MULTIPLIER_OUTPUT_TYPE2  <-  solve(diag(LEN-8)-TYPE2_A)
HH_VALUE_ACCOUNTS <- (nrow(MULTIPLIER_OUTPUT_TYPE2  )-5):nrow(MULTIPLIER_OUTPUT_TYPE2  )
TYPE2_MULTIPLIERS_TOTAL <- colSums(MULTIPLIER_OUTPUT_TYPE2[-HH_VALUE_ACCOUNTS ,])
TYPE2_MULTIPLIERS_TOTAL 



