Justin Barrett is a cognitive psychologist who works in this area, but he is also a committed Christian. In a recent presentation at the Veritas Forum, he describes the current state of the psychology of religious belief and then concludes that god, and the Christian god in particular, is probably behind it all.
I will briefly review his summary of the science and then examine his conclusions. Referring to the work of Paul Bloom, Steward Guthrie, Jesse Bering, among others, Barrett explains that humans are predisposed to detect intentional agency in their environments. We assume that agents act with intent and purpose, and we attribute all sorts of mental states (e.g., goals, desires) to them. Collectively, these predispositions are known as "Theory of Mind" (ToM), and they tend to work well. Perhaps the chief advantage of ToM is that it is a great shortcut. Barrett uses the example of yawning. We readily infer that a yawner is tired or bored. We do not describe the yawn in terms of the physical transactions of matter and energy that take place. Barrett notes that children are enthusiastic mind readers. Although they make distinctions between agents and objects, they favor the former. Education, according to Barrett, is a way of reigning in assumptions of mind.
The standard conclusion in the cognitive psychology of religiosity is that beliefs in supernatural agents are byproducts of a system that works reasonably well, and that is designed to minimize the probability of overlooking a mindful agent. Since the system, like all systems, is imperfect, the false positives in agent detection are the price paid for keeping the number of false negatives small.
All this suggests the conclusion that god is an illusion and Barrett quotes Bering to this effect. To counter this conclusion, Barrett quotes a "logician and Christian philosopher" who asserts that showing how natural processes can create supernatural beliefs does nothing to discredit these beliefs. This is not quite right, and a logician should know this. If scientific evidence shows that natural processes of mind, which have evolved to solve non-religious problems, can give rise to beliefs in the supernatural, then it has been shown that god is not a necessary cause of such beliefs.
Barrett tries to get around this problem by suggesting that "perhaps god designed us in a such a way that it is by virtue of those processes that we have knowledge of him." This is an interesting idea, but it is entirely circular. According to this logic, whatever science can uncover about the psychological bases of belief is consistent with the idea that god created the cosmos. Anything anybody can ever find, argue, or assert, will be consistent with the idea that god designed the world so that this would be so. In Barrett's words, "If god orchestrated the cosmos such that that we evolved in this way, he is behind it at the end of the day."
Barrett may have wanted to rest his case here and live knowing that he has proved nothing. But he ambitiously presses own in search of scientific respectability for his point of view. He brings in Bayes' Theorem, which deals in probabilities and how they are related to one another. Barrett compares two conditional probabilities.
The first conditional probability is this:
"If there is a god, one that is powerful, knowledgeable, and involved in the creation and shaping of the world who also wants us to come to know him, how probable is it that there would be natural dispositions to believe in some kind of god like this?"
The second conditional probability is this:
"And if there is no such god of this sort, how probable do you think it is?"
Let's represent the first conditional probability as p(B|G), where B stands for belief and G stands for god. If we take Barrett by his word, this probability would have to be 1 because if god is omnipotent (as Christians believe) and if he wants to be believed in, he very well can make it so. But perhaps he is whimsical, and chooses, in his inscrutable wisdom, a probability less than 1.
Let's represent the second conditional probability as p(B|~G), where ~G stands for "no god." Cognitive psychologists think that what they are doing is to drive up this probability.
Barrett asks us to accept the idea that p(B|G) > p(B|~G) and to agree that we have at least some support for Christian theism over atheism (n.b., I do not know where that leaves other monotheists).
Now let's rewrite the two conditional probabilities following the Reverend (yes!!) Bayes.
p(B|G) = p(B) x p(G|B) / p(G), i.e., the probability of belief if god exists equals the overall probability of belief times the probability of god's existence if we believe divided by the overall probability of god's existence.
Analogously, p(B|~G) = p(B) x p(~G|B) / p(~G).
Barrett's inequality can now be rendered as a ratio.
p(B|G) > p(B|~G) = p(B|G) / p(B|~G) > 1, and
(p(B) x p(G|B) / p(G)) / (p(B) x p(~G|B) / p(~G)).
We see that p(B) cancels out, leaving
(p(G|B) / p(G)) / (p(~G|B) / p(~G)), which can be written as
(p(G|B) / p(~G|B)) x (p(~G) / p(G).
We can say nothing about the ratio of p(~G)/p(G). Since the probability of god's existence is to be found rather than assumed, we may want to set the ratio of these prior probabilities to 1.
Now Barrett's argument reduces to
p(B|G) / p(B|~G) = p(G|B) / p(~G|B)
His argument that it is more likely that we believe in god if he exists and makes us believe in him than that we believe in the absence of such an agentic god is equal to saying that it is more likely that god exists given that we believe in him than that god does not exist given if we believe in him. In other words, the belief in god is evidence that god exists.
This is of course nonsense because it is the validity of the belief that is at stake here. A belief cannot serve as diagnostic evidence for its own truth.
Moving from Bayesian probability to logical implications, Barrett's argument comes to this:
 I believe in god.
 God has made me so that I believe in him.
 Therefore, god exists.
Later in the debate, Barrett makes a similar argument to defend his belief in free will. The impression of having free will is very strong. Therefore, he concludes, there is probably some truth to the idea of free will. We can replay the Bayesian drama by replacing G with FW (Free Will) and see again that the attempt to use a belief as evidence for its own validity is futile. Evidence must be based on recordable and shared observation. Bertrand Russell knew this (see epigraph) and he cheerfully rejected supernaturalism.
Interestingly, the Reverend Bayes probed into the relations among probabilities hoping he could use this calculus to find probabilistic support for the belief in god. He understood the limitations of his own method better than Barrett does. His essay was published only posthumously. Bayesian statistics play a tremendously enriching role in empirical science. As the Reverend knew, they do nothing for metaphysics.
For good measure, two more notes on Barrett.
 Barrett claims that the debate over the existence of god (if there is such a debate) should be reframed so that the burden of (dis)proof lies with the atheists. If theistic beliefs are so widespread and deeply held, it is the atheists who must establish the falsity of these beliefs. This attempt at reframing the issue after a thousand years of failed proofs of god's existence is at least understandable from a psychological perspective. Yet, throwing this gauntlet is meaningless unless it comes with at least one falsifiable hypothesis. Nobody knows, though, what such a hypothesis would look like. Evidence is by definition a matter of the natural world and therefore can say nothing about the supernatural.
 Barrett notes that according to studies, religious beliefs and practices are correlated with cooperative behavior, mental health, and other indicators of well-being, and he sees this correlation as caused be god. Hence, he counts the pragmatic benefits of religiosity as evidence for the truth of its belief claims. I always thought that the idea of pragmatism that beliefs can become true in their consequences is tongue-in-cheek. It is more "pragmatic" for a person to share the religion of his or her own tribe than to adhere to the religion of a far-away tribe. It makes life easier and bestows the benefits of community. It does not make the tribe's particular religious beliefs any truer.
The argument that monotheistic religion is better for humans than other forms of spirituality (or no spirituality) is also dubious. Many of the ancestral populations of today's monotheistic nations were converted by the sword, and Jonathan Swift observed that wars between different monotheistic creeds were among the bloodiest. Where is the pragmatic benefit?