If a police officer stops you, he or she may ask to see your ID and ask you to identify yourself. Do you have to produce this identification?
In short, you don't. Laws do vary from state to state, but New York law does not make it mandatory for you to have an ID card on you or to show it to the police. They can ask, but they can't arrest you for refusing or for not having the card in the first place.
Naturally, this goes for situations in which you are a pedestrian. If you're driving a car and they ask to see your driver's license, you have to produce it.
One important thing to note is that you can be detained if you don't have an ID and the police are arresting you or if you have been issued a summons. They need a positive ID in these cases, so they can detain you until it is obtained.
The police can also stop you briefly if they think you were involved in a crime, even if you weren't. They do need reasonable suspicion, though, and you can ask them if you're free to leave or if you're being arrested. If you're not being arrested, you may be able to go.
However, it is not advisable to run from the police. This is true even if you didn't do anything wrong and you think you shouldn't be detained. Running can lead to an arrest by providing the police with reasonable suspicion, so you're just giving them what they need. You're far better off to stay calm and ask if you're free to go.
Were your rights violated during an arrest, perhaps because you didn't have ID? If so, you may be able to use that in court to fight to have the charges dropped.
Source: NYCLU, "What To Do If You’re Stopped By The Police," accessed Sep. 19, 2016