Fandom, it turns out, is a surprisingly clear window into our brains, and into how loyalty in general works. Sports teams, in this light, are not just groups of athletes in competition with each other, but rather complex systems that are designed to secure our allegiance by seizing upon our human needs and vulnerabilities. Think of them as loyalty-making machines, which exist to create fans out of people who might not otherwise care about them by reaching into their heads and pushing the right buttons.

Why are some teams so easy to love and obsess over? What would it take for the Sox to truly lose the loyalty of their fans? As specialists in psychology, media studies, and marketing consider these questions, what they’re finding is that loyalty in sports is a deeper matter than just following the Sox because they’re from Boston, or hopping on and off the bandwagon as the Patriots’ fortunes rise and fall. Having a winning record, these researchers have found, is just a small part of what makes franchises like the Sox, or the Celtics , or the Bruins, the objects of intense dedication. Instead, their findings point to a variety of factors that contribute to fanship, including our instinct for tribal affiliation, our desire to participate in tradition, and our hunger for compelling characters and dramatic story lines.

It may seem bizarre to argue that a team can strengthen its bond with the people who feel invested in its success by getting its butt kicked. But the link between losing and loyalty is less puzzling to experts in the growing field of fan studies, a burgeoning effort in the academy whose practitioners are interested in how sports fans think and why they feel as intensely as they do about their favorite teams.

Of course, it was exactly the wrong question. As Globe columnist Brian McGrory suggested on April 8, that dreadful opening stretch was the best thing that could have happened to this year’s Red Sox and their fan base. The team everyone had expected to tick off one easy victory after another had proved itself deeply vulnerable. Suddenly, rooting for the Sox would feel like it mattered again.

But the Red Sox declined to be constrained by those expectations. Instead, they came out of the gate defiantly terrible. As a disappointing opening-night loss turned into a helpless weeklong streak, people stopped dreaming about 100 wins and started wondering instead how much disappointment Sox fans were going to put up with before they started bailing.

Before they lost six games in a row during the opening week of baseball season this year, the Boston Red Sox looked invincible. Unapologetically stacked, with no weak spots in their lineup and two expensive, freshly bought stars in Carl Crawford and Adrian Gonzalez, the team seemed destined to win 100 games before strolling into the World Series and winning that too.

Haridakis, who teaches at Kent State University, has focused his fan research on what he calls “social identification,” a fancy term for various forms of tribalism that find expression when people start seeing themselves as part of a group with a common purpose. The more loyal a fan is to the sports team he or she loves, the more stubborn that sense of identification will be: Speaking of less devoted fans, Haridakis cited the term “CORFing,” which is an acronym for “cutting off reflective failure” that refers to people’s tendency to distance themselves from a losing team by talking about it in the third person. Diehard fans don’t do much CORFing, Haridakis said, though they are known to “BIRG”—“bask in the reflective glow”—by saying things like “We won!” when their team prevails.

“People become passionate about sports because of certain needs they have,” said Haridakis. “What makes someone stay loyal to a losing team? What makes a fair-weather fan bail as soon as a team starts losing?”

Adam Earnheardt and Paul Haridakis, a pair of professors who have coedited an anthology of essays on fanship called “Sports Mania,” are preparing a study that will determine which team in the United States has the “best,” or most devoted, fans. By isolating the differences between people who obsessively check scores and wear throwback jerseys and those who tune in and pay attention every once in a while, Earnheardt and Haridakis hope to find insights about the underlying causes of loyalty and group identification.

Before we go any further, it’s important to note that fanship runs along a spectrum—one that researchers have spent a lot of energy trying to define over the years. One scale, developed by fanologists George Milne and Mark McDonald in 1999, puts casual fans who get a kick out of watching the occasional game on one end, and runs all the way to the guy who skips out on his brother’s wedding to watch the playoffs. Somewhere in the middle you might find less personally invested fans who start caring about a team only when it is playing in a championship.

The people of Boston have plenty of occasion to mull such things at the moment, as the Celtics face off against their New York rivals, the Bruins struggle against their ancient nemesis from Montreal, and the Sox work to get their swagger back. While the outcomes of all the games those teams are playing will undoubtedly matter a great deal, there’s a way in which the real competition is for our long-term allegiance. And the extent to which our loyalties hold through thick and thin, it turns out, may tell us less about the athletes we follow than it tells us about ourselves.

“[Fandom] isn’t often looked at as a distinct cultural phenomenon,” said Daniel Cavicchi, an American studies professor at the Rhode Island School of Design who maintains a blog about the history of fan culture. “We pay so much attention to stars and to teams and to games, that we sort of tend to ignore the audience, or assume the audience is just there—that they’ve paid for their tickets and they’re showing up. But actually there’s a lot going on.”

Great story lines get people invested in a team’s progress, according to experts who have studied media coverage of sports. “Stories matter,” said Walter Gantz, a communications professor at Indiana University. For an example of this, one need look no further than what is perhaps the greatest narrative of modern Boston sports: the 2004 Red Sox postseason, in which they dramatically battled back from an 0-3 playoff deficit to the hated New York Yankees and went on to win the World Series for the first time since 1918.

If tribalism and honor exert a strong pull, there may be an even more powerful force at work in getting fans addicted to teams: the human need for narrative. Especially for franchises with long histories, like those in Boston, a big part of what hooks fans—what pushes a casual fan deeper into the spectrum—is the multitude of story lines that can be seen in longstanding rivalries, the career arcs of players, and of course, individual games.

In many cases, research has shown, that tribal connection goes back to a fan’s childhood, when parents or siblings encouraged him or her to root for a particular team. Jonathan Gray, editor of “Fandom: Identities and Communities in a Mediated World,” compared the inheritance of sports fandom to the way in which preference for particular soap operas tends to be passed down within families from one generation to the next. “If a grandma watches one soap, then the mother watches that soap, and the daughter watches that soap,” Gray said. “It’s something you can all talk about.” By the same token, he said, love of the Sox or the Bruins can be imprinted on a child at an early age, and grow from mere imitation to a way to pay homage to one’s family, or school, or neighborhood.

Such calculations are related to what Kevin Quinn, a professor at St. Norbert College and author of “Sports and Their Fans,” refers to as tribal affiliation. “Humans are inherently tribal creatures, and this is a way to have a tribe,” Quinn said.

Rich Campbell, a marketing professor at Sonoma State University, has argued that fans’ self-esteem doesn’t always come from winning: Sometimes they feel more honorable and individualistic if they see themselves as part of an embattled but proud group. Campbell also cites teams like the Dallas Cowboys , which transformed from very bad to very good during the 1990s and in the process accrued stadiums full of new fans while alienating old ones who didn’t want to be associated with the Johnny Come Latelys. (In Boston, this alienation takes the form of rants from longtime fans about neophyte “pink hats.”)

BIRGing and CORFing aren’t hard to understand: Most people just want to see their favorite teams win, and they pull away when the losing becomes a pattern. But that’s not the only way people respond to their teams. Lots of losing teams have maintained extremely loyal fan bases, while some very successful teams have actually lost the allegiance of certain fans even as their performance has improved. And that’s where things get interesting.

Richard Johnson, curator at the Sports Museum of New England, got audibly emotional as he talked about that particular narrative last week over the phone, saying he didn’t think a novelist could have gotten away with writing it the way it really happened—no one would ever buy such a perfect plot. Not only was it a storybook come-from-behind victory against the bitterest of rivals, Johnson said, “there was also Curt Schilling’s bloody sock!”

Compelling story lines tend to involve not machinelike excellence (like the Yankees, or the preseason Sox of this year), but flawed teams, like the Red Sox of the Impossible Dream season in 1967, or the young Patriots of 2001. “For a team to be lovable, it helps not to be great or too great, but rather to have a chance to win or get lucky,” said Lawrence Wenner, a professor at Loyola Marymount University, author of the book “MediaSport,” and the former editor of the Journal of Sport and Social Issues.

Narrative has a self-reinforcing property: The more enmeshed in the story you become, the more fun it is to pay attention to a game that gets you deeper into the story. When you know a team deeply, experts point out, you’re able to keep track of multiple story lines at once. If you knew that the Larry Bird-Magic Johnson rivalry stretched back to their college years, the Celtics- Lakers rivalry of the 1980s was that much more engrossing.

“The more you know about the history of the Red Sox, the more meaningful the experience of watching them play is,” said Quinn. “There were probably a lot of non-dry eyes among people who aren’t typically emotional [when the Sox won the 2004 World Series], and it’s because they were plugged into that soap opera.”

That said, as much as it felt like a soap opera, part of the reason it was so intense was that it wasn’t one—there was no script, no guaranteed ending. That series was as real and unpredictable as it gets. And that might be the most important point of all to make about how a team grabs our minds. Sports experts call it “eustress”—the addictive combination of euphoria and stress that grips fans in the presence of a game, and becomes only more intense when the games are close. Studies have shown that rewards delivered at unpredictable intervals have especially powerful effects on our animal brains, and are decidedly more pleasurable and addictive than rewards that arrive on a set schedule. Is there a better description of a sports season?

Think of it next time you’re watching a Red Sox game and you see a swarm of costumed maniacs flailing about in the bleachers with their faces painted and their voices cracking. Even if the score is 15-0 in favor of the other guys, maybe just take a second to reflect on what’s happening: They’re not just rooting because they want Boston to win, or because they want to see Papi hit a home run. They’re rooting—and, suddenly, you’re rooting along with them—because this abstract institution called a baseball team has enchanted and captivated them at a level they may not even control, worming its way into their brains and tickling them, with precision, in all the right spots. Do you really need 100 games?

Leon Neyfakh is the staff writer for Ideas. E-mail lneyfakh@globe.com.

© Copyright 2011 Globe Newspaper Company.