First-principles investigation of ferroelectricity in perovskite compounds