The construction of the NGM involves the use of compartmental models, such as the SIR (Susceptible-Infectious-Recovered) model or the SEIR (Susceptible-Exposed-Infectious-Recovered) model. These models divide the population into different compartments based on disease status. The matrix is derived by linearizing the system of differential equations around the disease-free equilibrium and then calculating the average number of secondary cases produced by each infected individual.