One of the most common statements we hear from training clients, particularly people who are training their first dog, is that the dog "knows" a behavior, but will only execute it in certain situations.
He sits inside, but not outside. She knows to come when we're in the backyard, but the second we start hiking, she completely ignores us. He totally forgets his manners when he meets new people!
The reaction is sometimes to punish the dog for "blowing you off." However, it's much more helpful to understand why the dog isn't complying, and I'll give you a hint: it's not insolence. It's because for dogs, context is everything.
Say you teach your dog to sit in the kitchen by putting his food in the bowl and only putting the bowl down if he sits politely and waits until you say "ok." This is a terrific way to help your dog learn to sit and also to teach him some self control. However, if you're a dog, you haven't just learned how to sit on command. You've learned to sit on command in the kitchen when your owner is holding a bowl of food. Your dog has no way of knowing which parts of the context and his behavior led to the reward of getting to eat the food.
If you move to the living room and use a handful of treats instead of a bowl of food, your dog may have trouble generalizing the behavior. In the kitchen, there was the hum of the fridge behind him, the feel of the laminate under his paws, the bowl over his head, the counter to his left, and the human is standing still. In the living room, the hum of the fridge is distant, there's carpet under his paws, the bowl has disappeared, there's an armchair to the left, and the human is gesturing. It can be difficult for the dog to understand that the common element that's so obvious to the human, the word "sit," is the important part.
That's why we typically teach things like the sit with both a hand gesture and a verbal cue. The hand gesture is easier for the dog to recognize between contexts, and then we can fade it away later if we want the dog to be able to execute the skill without the gesture. Even so, making a skill truly reliable in multiple locations involves more than just the gesture. It means helping the dog understand what the crucial parts of the sit are and what things are irrelevant.
If you could explain it to the dog, you'd say, "Sit means plop your rear end down immediately, regardless of where you are, and hold it there until you receive further instructions." However, your dog won't generalize the skill to new locations or learn that sitting next to you is the same as sitting in front of you unless you teach him. And don't forget that, depending on where you are, there may be sounds and smells you can't even detect that are screaming for your dog's attention.
So it's absolutely crucial that you practice all of your dog's core skills in different environments and with different kinds of distractions. And, when you do, you need to remember that a new context means your dog may not understand the skill. Never punish a dog for his failure to generalize; it's neither sporting nor effective. Many situations where the human is saying, "He knows it. He just doesn't want to do it" are really situations that involve the dog's failure to generalize.
Instead, assume that noncompliance means your dog doesn't truly understand, and teach the skill from scratch. He knows sit in the house but won't do it in the backyard? Teach it from scratch in the backyard, just like you did in the house. You should find that your dog will start to figure out which parts of the cue and the skill are the same every time. For example, each time he learns "sit" in a new context, he should learn it faster as he discerns the fact the cue ("sit") and the behavior (rear end on ground) are the important parts of earning the reward.
Context goes beyond just the surrounding sounds, sights, and smells. The dog's position relative to you matters too. If you only practice sit with your dog in front of you, facing you, that is what "sit" will mean to him. He won't necessarily understand what it means when you're walking him on the leash and you want him to sit beside you, facing in the same direction. So be sure to practice sit in front of you and on both sides of you as part of teaching your dog to generalize it
Also, as you engage in the process of teaching context, it really helps to escalate your distractions gradually, since they're a key part of the dog's context. Don't teach your dog "come" in an empty room and then ask him to do it off leash at a chicken farm the next day. Work up gradually through escalating distractions, always making sure to set your dog up to succeed and to prevent self-rewarding if he doesn't comply. Once he knows sit in the house and the backyard, stop and practice it a couple of times out on walks. When he can handle that, go to the coffeeshop patio on a quiet day and work on it in the corner. Then practice in the house again, but put a nature special on the TV and see how far back to basics you have to go when there are geese calling and flying by in hi-def.
Group classes, by the way, are an invaluable way to help teach a dog to generalize a skill. Each time we teach Family Dog Training Basics, we warn the students that their dogs' obedience will go out the window during the first session and that it's a good thing in the long run. Even a dog who's pretty good in the house and backyard will typically lose his obedience when brought into a dog training center and asked to execute his skills with five other dogs in a large room. But when the dog learns or relearns those skills in that distracted environment, you're setting him up to generalize his sit, stay, loose leash walking, and recall so they hold up out in the real world when you need them. In fact, one thing you'll see at a training center's group classes is that the trainers will bring their own young dogs, even when it's a class they've taught a million times. They're not there to learn the curriculum; they're there to practice with a dog in the environment and to get pointers from other trainers.
So the next time you're frustrated because your dog "knows it" but isn't complying, try to consider the way a dog sees the world and the way he learns new skills. For you, sit means sit, but for your dog, sit may mean something much more difficult to generalize. Humans are great at generalizing, but when you're a dog, context is everything.