Portugal survived a scare and a missed Cristiano Ronaldo penalty as they beat Latvia 4-1 in Sunday's World Cup qualifier.