Kenya has suffered the far-reaching effects of repeated attacks by Somalia-based Al-Shabaab terrorist group for years. Tourism has declined. Jobs have been lost and foreign direct investment has withered. The greater Horn of Africa region bordering Somalia has also suffered, but statistics indicate that Kenya experiences an inordinate number of attacks by the terror group.

This trend cannot be explained by geography alone. Granted, Kenya's porous and ill-guarded borders does make it easier for terrorists to infiltrate the country. But Ethiopia has a much longer border with Somalia than Kenya does.

Between 2006 and 2007 Al-Shabaab conducted few attacks outside of Somalia. There was only one terrorist attack in Ethiopia; there were none in Kenya. In contrast, between 2008 and 2015, the group executed a total of 272 attacks in Kenya and only five in Ethiopia.

Some scholars have focused on Al-Shabaab's retaliation for Nairobi's armed intervention in Somalia, beginning in late 2011, as the reason for Kenya's woes. Yet Ethiopian forces have been in Somalia for more than a decade and both Burundi and Uganda contribute heavily to the African Union Mission In Somalia (AMISOM).

It is also worth remembering that the incursion by the Kenya Defence Forces (KDF) was itself a reaction to Al-Shabaab attacks within Kenya that date back to 2008.

So what explains Al-Shabaab's focus on Kenya? Our research indicates that Al-Shabaab attacks critical Kenyan targets for both logical and opportunistic reasons. They are based on geographical proximity to Al-Shabaab's bases in southern Somalia and reinforced by other variables that play into terrorist groups' general modus operandi.

For example, attacks such as those perpetrated by Al-Shabaab in Kenya exploit existing opportunity spaces and can be referred to as "propaganda by deed". In this, they seek to raise attention to the group's existence and viability, thereby enticing recruits to its ranks and spreading fear. In essence, the larger and more brutal the attack, the more the group is perceived as potentially more relevant and powerful than it possibly is.

Indeed, Al-Shabaab's attacks in Kenya have been characterised by their gruesome effect and have attracted critical news coverage internationally. This gives Al-Shabaab a level of publicity, notoriety and international relevance that often belies its increasing isolation in Somalia.

Why Al-Shabaab targets Kenya

Al-Shabaab's current - though shrunken - stronghold is in southern Somalia. The geographic proximity of southern Somalia to targets in Kenya makes it easier to plan and launch terrorist attacks. The terror group has attacked not only Nairobi, but Mandera and Garissa in the north-east, as well as Kenya's tourist-filled coastline. In contrast, potential targets such as Addis Ababa, Djibouti or Kampala are geographically distant and logistically difficult to reach.

Kenya is also one of sub-Saharan Africa's most important states and East Africa's hub. Its international visibility and status lead Al-Shabaab to make conscious decisions and efforts to attack it. Attacking targets in Kenya, particularly in Nairobi or on the coast, guarantees Al-Shabaab a level of international coverage that a similar attack in Ethiopia, for example, would not.

Most international media operate freely in Kenya. Many outlets, such as Xinhua, CNN and Al-Jazeera base their Africa operations in Nairobi. The media coverage given to horrific attacks here presents presents Al-Shabaab the "oxygen" it needs to survive and, potentially, thrive.

Kenya's highly-developed tourism sector is another target. The cumulative result of attacks and terrorism related travel advisories has been a marked decline in the number of tourists visiting the country since 2013. This has also led to hotel closures and job losses along the entire tourism supply chain.

This appears to bleed into arguments that posit Al-Shabaab attacks Kenya to bring it to its knees economically, influence foreign policy and force it to withdraw from Somalia. We argue that while this is partially true, it is not the only reason Al-Shabaab attacks Kenya's tourist spots. Rather, it attacks Kenya because it's a tourist hub and offers ample, opportune targets for terror.

Finally, Kenya's security services are reportedly riddled with inefficiency and corruption. Al-Shabaab has exploited this fact. There have been strong allegations as well as hard evidence that Kenya's police and military have occasionally colluded with Al-Shabaab.

What Kenya can do

Kenya needs to squarely face this reality and take appropriate measures to counter a persistent and therefore predictable threat.

This does not imply that the Kenyan government should anticipate the location or timing of attacks. But it should be aware of and take appropriate measures to counter this threat.

Research has demonstrated that the most promising way to reduce terrorism is to reduce the terrorists' confidence in their ability to carry out attacks. Kenya needs to proactively address border security and revamp national security apparatuses.

But before shelling out money for the recruitment and training of more security and military personnel, Kenya must firmly deal with the omnipresent bugbear of corruption. Research on the proposed Kenya-Somalia border wall, for example, demonstrated it will have little positive effect if the design and construction are simply vehicles for corruption.

Walls may stop some determined terrorists but they are largely useless if guards are susceptible to bribes and let attackers through. In 2014 two Al-Shabaab affiliated border guards bribed Kenyan border guards to escort them from Somalia to Mombasa. The two were later captured in the city driving a vehicle stuffed with automatic weapons, rounds of ammunition and almost 50 kilograms of explosives.

The overall lack of training and professionalism in the security sector must also be addressed. Close attention should be paid to the well-being and quality of security personnel and equipment at installations ranging from shopping malls to private homes, government buildings and borders.

Third, the Kenyan government has been unable or unwilling to effectively counter negative news stories and Al-Shabaab propaganda that paint the country as a "hotbed of terror". The fact remains that some states, including Kenya, appear to suffer more from the public perception of instability and danger from terrorism than others. These perceptions often correspond little to reality or statistics.

Terrorism is a region wide problem. It makes sense for Kenya to work with Somalia and Ethiopia on shared borders, refugees and the like.

Yet Kenya must also understand that it is the primary Al-Shabaab target outside of Somalia. No amount of regional cooperation will entirely alter that. As such, it must attempt to positively and consistently address the reasons why it is the target of attack largely on its own.

Dominic Ruto Pkalya contributed to this article and the research it cites.

AllAfrica publishes around 800 reports a day from more than 140 news organizations and over 500 other institutions and individuals, representing a diversity of positions on every topic. We publish news and views ranging from vigorous opponents of governments to government publications and spokespersons. Publishers named above each report are responsible for their own content, which AllAfrica does not have the legal right to edit or correct.

AllAfrica is a voice of, by and about Africa - aggregating, producing and distributing 800 news and information items daily from over 140 African news organizations and our own reporters to an African and global public. We operate from Cape Town, Dakar, Abuja, Monrovia, Nairobi and Washington DC.