The woman who died when she was hit by the Amtrak Downeaster in New Hampshire last week was a 22-year-old former high school valedictorian from Wells.

Police in Durham, New Hampshire, identified the woman Monday as Brandi L. MacDonald, a well-liked student in Wells who had been attending the University of New Hampshire. She died Sept. 24 after she laid on the railroad tracks and was hit by the train near the boundary between Durham and Newmarket, according to Durham police.

Her death was ruled a suicide by the New Hampshire Medical Examiner’s Office.

MacDonald’s death just south of the Maine-New Hampshire border followed four incidents since March in which people were struck and killed by the commuter train in southern Maine. Three of the four fatalities were ruled suicides. Two of those suicides occurred in North Berwick since July, including one four days before MacDonald’s death.

There are 300 to 500 train suicides nationally each year, according to the U.S. Federal Railroad Administration.

MacDonald, who was valedictorian of the Wells High School Class of 2010, was remembered Monday as a good-natured and sweet young woman who excelled academically. During high school, she was a member of the math team and received numerous academic awards.

“She was kind and would do anything for anyone. She was a brilliant young lady,” said Wells High School Principal Jim Daly. “When you look at kids all parts being equal, she was a high-flying, great kid.”

Daly said grief counselors have been available to students at the school, where MacDonald’s younger sibling is a student.

“It’s a tremendous loss for our community,” Daly said.

MacDonald was the daughter of Diane Griffin and Charles F. MacDonald, according to graduation information provided by Wells High School in 2010.

MacDonald’s parents could not be reached Monday. An aunt said she was too upset to talk about her niece.

Her high school graduation profile also said MacDonald planned to study engineering at the Massachusetts Institute of Technology. It was not clear Monday if she enrolled there after high school.

MacDonald had most recently attended the University of New Hampshire in Durham, where she was last enrolled for the fall 2013 semester, according to a school spokesperson. From 2011 to 2013, she was named to the UNH dean’s list each semester with highest or high honors.

Maine has a higher rate of suicide among 15- to 24-year-olds than the national average and the highest rate in the Northeast for that age group. From 2005 to 2009, the most recent data provided by the state, there were 901 suicides in Maine, of which 93 were committed by people younger than 24. Suicide is the second leading cause of death among Mainers aged 15 to 34, according to the federal Centers for Disease Control and Prevention. On average, there is one suicide every two days in Maine.

Maine’s statewide crisis line is available 24 hours a day at (888) 568-1112. The National Suicide Prevention Lifeline can be reached at (800) 273-8255.