A spatial panel data model with time varying endogenous weights matrices and common factors