Knowing what your opponents have is an art, not a science. Many successful (and unsuccessful!) poker players talk about "tells" - twitches, trembles, and other bodily signs that might give you a clue as to what your opponent has. In time, you may even learn to be able to "read" those tells. Mastering the psychology of poker, however, is much more important (and, in fact, a crucial foundation before reading tells is even possible).
Poker psychology boils down to your ability to watch how others play, and use that experience to judge how your opponents may be playing in the current hand. It is critical that you never become distracted from the game. For example, do not watch TV, even during a friendly game, for this will deprive you of the information you gain while watching your opponents. Even in a friendly game, your "friends" are trying to take your money from you!
The simplest layer of poker psychology is to watch what your opponents visibly do based on their own cards. For example, keep track of how each player bets. If you have problems doing this, start by only keeping track of those who did not fold, and don't worry about keeping track of amounts. Simply get a feel for whether the players bet strongly or weakly. During a showdown, note the hands each player had. Were they betting heavily with a weak hand? Was the hand possibly going to "make it?" (e.g., were they drawing to a flush, and just didn't make it? Was the flush even possible? Was it likely, or was it a long shot?)
This is not a skill learned in a day. You must play THOUSANDS of hands to master it. Gradually, you will build a feel for how players bet in response to what they have in their hands. Then focus on how they respond to other players. Did they come out betting heavily early in the game, then fade away and eventually fold to heavy raising, even if their hand looked like it improved? Did they instead re-raise or cap the betting?
The same mathematical strategies that apply to you can be of assistance here, especially in community card or stud games, which give you some information about what the other players have even before the showdown. In fact, it is during these games that poker psychology is most readily learned, because in draw games you never know what the player discarded.
Learn to classify your opponents, and adjust your strategy against how they play. For example, identify whether your opponents are loose or tight. If they are loose, they are likely to bet heavily or stay in for a long time with even a very weak hand, or on a long shot draw. Tight players, however, tend to fold at every breeze. Also categorize them in terms of passive or aggressive. When raised, do they tend to call or fold? Or do they re-raise?
Ultimately, no single strategy will ever teach you the art of poker psychology. You will either learn it over a long period of time playing many hands, or you will go broke trying!