A psychiatrist told a federal jury yesterday that in the months before John W. Hinckley Jr. shot President Reagan, his actions were guided by the "inner dictates of an inner world" that had gradually taken hold of his mind as he became isolated from ordinary day-to-day life.

Dr. William T. Carpenter Jr., who has conducted 45 hours of interviews with Hinckley since the shooting, testified that as a college student Hinckley fantasized about his own "self-importance" and believed he had a "special leadership role . . . in bringing right-wing ideologies into American political life."

By 1977, he was reading Nazi literature and books about "newsworthy murders" including the assassinations of John and Robert Kennedy, he testified. In 1978, Hinckley wrote that he had "taken the big step and joined the Nazis."

In 1979, Hinckley concocted a group he called the "American Front," which he thought would be an acceptable middle ground between conservative Republicans and the Nazis and "bring the country to its senses" about minority groups, Carpenter testified.

Hinckley made himself the front's "national director," drew up a membership list of nonexistent persons and prepared detailed newsletters in which he said the front "must now come to the rescue of white Americans."

During those years, Carpenter told the jury, Hinckley began to identify more and more with the character of Travis Bickle in the movie "Taxi Driver," which he saw for the first time in 1976.

Carpenter, the director of the Maryland Psychiatric Research Center, was the first psychiatric expert called to testify by Hinckley's defense lawyers, who are trying to convince the jury that Hinckley was legally insane when he shot Reagan, his press secretary, a Secret Service agent and a D.C. police officer more than a year ago.

Carpenter told the jury that Hinckley, "living out" the identity of Bickle, bought guns and stalked President Carter but was "unable to get himself to a frame of mind to carry out the act."

Carpenter said Hinckley experienced "some relief" from his emotional despair when he used guns. Hinckley took photographs of himself--one of him holding an unloaded gun to his head and others while he held rifles--that were shown to the jury yesterday.

Hinckley became "intensely obsessed" with actress Jodie Foster, who played a young prostitute in the film, and believed that her movies were played on television to "excite him into action," Carpenter said. Hinckley was convinced that the only way out of his desperate feelings was to make contact with her, the psychiatrist told the jury.

After "disastrous attempts" to reach Foster by telephone and through notes and poetry, he said, Hinckley became more consumed with the Bickle character, who had tried to assassinate a presidential candidate in the movie. Hinckley bought guns to arm himself as Bickle had in the film and went looking in New York for young prostitutes who resembled the Foster character, Carpenter testified.

After the 1980 election, Carpenter said, Hinckley "lost interest in President Carter" and was "devoting his activities and his thinkings" to Reagan.

Carpenter and other psychiatrists for the defense and prosecution have all conducted scores of interviews with Hinckley since his arrest on March 30, 1981.

Their expert testimony, and their opinions on Hinckley's state of mind on the day of the shooting, are intended to help the jury decide the crucial issue of the trial: whether Hinckley suffered from a mental illness at the time of the shooting that prevented him from either obeying the law or understanding that his acts were wrong.

During questioning by defense lawyer Vincent J. Fuller, Carpenter told the jury that he had arrived at an opinion on whether Hinckley suffered from a mental disease when he shot Reagan. However, yesterday's court session ended before he told the jury about his opinion. His testimony will continue today.

During Carpenter's testimony, the jury also heard a tape recording that Hinckley made on Dec. 31, 1980, which he called his New Year's message to the world.

Carpenter told the jury that the tape, found when Hinckley was arrested, contains many themes, including insanity, suicide, homicide and kidnaping, that recur throughout Hinckley's prolific writings.

On the tape, Hinckley says that in the wake of John Lennon's murder that month in New York, "Jodie is the only thing that matters now . . . I wanna make some kind of a statement or something on her behalf. Just tell the world in some way that I worship and idolize her."

He describes his trips to Yale University, where Foster was a student, saying, "I've been up there many times, not stalking her really, but just looking after her." He said he wanted to take her away from there, but added: "I am so sick I can't even do that."

"I don't wanna hurt her or anything. I, I can't hurt anybody really. I'm such a coward really," Hinckley says on the tape. He talks about a "final pact between Jodie and me . . . I think about that a lot. That's really all I think about."

Before Carpenter took the witness stand yesterday, the jurors heard tape recordings Hinckley made of five telephone calls to Foster's dormitory room at Yale, two of them with Foster herself.

On the tape, Hinckley pleads for conversation with Foster, who at one point tells Hinckley that it is "dangerous" for her to speak to people she doesn't know.

"Well, I'm not dangerous. I promise you that," Hinckley said.

The jurors also heard a tape recording, made by Hinckley and confiscated after his arrest, in which he plays the guitar and sings two songs to Foster, one of which is similar to a song John Lennon wrote about his wife, Yoko Ono.

Hinckley, whose fantasies included fame as a rock star, looked at the jurors and smiled at one point as his high-pitched, and sometimes flat, voice filled the courtroom.

The death of John Lennon was a "profoundly important" event in Hinckley's life, Carpenter told the jury. It "stunned him out of the stalking of Ronald Reagan" as he began to focus on Lennon, but it also caused a more complex reaction in which Hinckley began to identify with both Lennon and Lennon's killer, Mark David Chapman, Carpenter testified.

After attending services for Lennon in New York and dropping offmore notes for Foster in New Haven, Carpenter said Hinckley described himself as in "total despair," his mind full of thoughts of homicide, suicide, death and the end of the world.

Hinckley was still feeling "like his fate was unfolding in a way he didn't know how to terminate," Carpenter said. Alone, desperate and "at the end of the road," Hinckley was unable to "get out of this mind set," Carpenter told the jury.

Hinckley concealed his inner world from the suburban Denver psychiatrist who treated him in the months befpre the shooting, Carpenter said. His continued struggle is reflected in his writings, the psychiatrist said, citing as an example a Hinckley poem titled "This Mind of Mine:" "This mind of mine doesn't mind much of anything, unless it comes to mind that I am out of my mind."