JointState messages only contain joint states, ie: joint poses in joint space. They do not represent Cartesian coordinates. So position[3] is not z, but the joint space position of joint 4 (it's zero-indexed).