When I am conducting interviews for puppy/dog adoptions, I tell them to budget between $1,500 - $2,000 per year for all the expenses of owning and properly taking care of a dog. They can be quite expensive.
Worth it, but potentially expensive.
Dogs "can" be great security, but to attempt to compare a dog against a weapon is not logical.
In some conditions a dog may be better
In other conditions a gun may be better
Perhaps the optimum solution is to have a dog AND a gun.