All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ʻalayhi wa sallam, is His slave and Messenger.
If this comparison is intended to draw an example with the aim of establishing or negating an attribute in relation to Allaah, then there is no harm in drawing this comparison by way of the 'analogy of the superior' (Qiyaas Al-Awla, in which the effective cause is more evident in the new case than the original case).
Ibn Taymiyyah wrote:
"Allaah is qualified with all the attributes of perfection, as He is the most perfect. There is no likeness between His attributes and those of His creation; therefore, it is impermissible to draw Qiyaas Ash-Shumool (analogy of equality) or Qiyaas At-Tamtheel (analogy of likeness) in relation to Him. Verily, this constitutes associating others with Him if it involves equating between Allaah and any of His creation. Rather, we may use Qiyaas Al-Awla (analogy of the superior). Indeed, there exists no comparability in anything between Allaah and His creation. The highest level of analogy is used for Allaah, which means that for every quality that is proven for the creature while Allaah is also qualified with it, then in that quality, the Creator is certainly superior to the creature. Similarly, any defect from which the creature is free, then the Creator is definitely the worthiest of being free from it. Allaah, The Exalted, is most worthy of the attributes of perfection and most deserving of negating all aspects of imperfection in relation to Him." [Majmooʻ Al-Fataawa]
Hence, the only analogy that is permissible between the Creator and the creation is Qiyaas Al-Awla, as dictated by the Quran. Ibn Taymiyyah cited examples on the usage of this type of analogy as he said:
"Imaam Ahmad and other scholars followed this approach laid down in the Quran and Sunnah, namely the sound intellectual approach of applying only Qiyaas Al-Awla in relation to Allaah. Qiyaas Al-Awla means that if a created being is qualified with a praiseworthy attribute, then the Creator is worthier of it. On the other hand, when an imperfection or a defect is negated in any created being, then it must be negated in Allaah with greater reason. Allaah, The Exalted, says (what means): {He presents to you an example from yourselves.} [Quran 30:28] and (what means): {And when one of them is given good tidings of that which he attributes to the Most Merciful in comparison, his face becomes dark, and he suppresses grief.} [Quran 43:17] In refutation of their claims of attributing partners and daughters to Allaah, the verse underlined that they deemed themselves too exalted of having daughters because they perceived it as a deficiency and manifestation of imperfection; if they could not tolerate such a thing for themselves, then how come they attribute it to their Lord..." [Bayaan Talbees Al-Jahmiyyah]
Hence, it is permissible to say that Allaah is worthy of praise and gratitude, and it is an ugly trait to meet His favors with ingratitude. If it is considered ugly to reward the favors and acts of kindness of people with ingratitude, then surely Allaah, The All-Generous, is more deserving of praise and gratitude. This falls under the heading of Qiyaas Al-Awla. Every aspect of perfection that we think of in the case of created beings and is free from all defects is to be affirmed for the Creator first and foremost; similarly, every imperfection that we think of in the case of created beings is to be negated from the Creator prior to anyone else.
Allaah knows best.