This is one of the strangest images in movie history, and “The Shinning” never explains it. To understand it, you have to go back to Stephen King's book.
Years earlier, the hotel belonged to Horace Derwent, a rich and powerful man. Roger was his lover, and he would do anything to please him.
One night, at a costume party, Derwent decided to humiliate Roger in front of everyone. He made him wear a dog costume, crawl on the floor, and do tricks like a pet. If Roger obeyed, Derwent promised, they would spend the night together.
That cruel night never left the hotel. It became one of its many ghosts. When Kubrick made the film, he turned the dog into a bear and cut almost the whole story, leaving only that disturbing moment.