Thursday, March 19, 2015

Twitter Sentiment Analysis in R

This has been one of the hardest projects I've taken on.

I've never been asked to do this. It's just for fun, but it was challenging. I'm used to coding in Java, and since I figured using R might help me in the long-run, it would be nice to able to do some things worth mentioning.
With that being said, I got interested in using Twitter's API to analyze tweets, and I ultimately came across this YouTube video on Twitter Mining and Sentiment Analysis.



I liked the video. Michael Herman admitted he wasn't very experienced with R at the time he made his video, but he still managed to execute the code and get sentiment analysis off of the tweets he extracted. This particular method of sentiment analysis seems to be widely used as far as R-Twitter tutorials are concerned. There are a few problems though. One, this video was published on 2012, which is important to note because there may have been some changes in the R versions and Twitter API between now and then. Two, the R-code for the Sentiment Scores function can use a few tweeks, if not a complete re-do; and three, there's not a lot of channels that have an updated version of this tutorial.

The sentiment scores function (or method) is just a R-Programming method someone made to help the user with sentiment analysis, a process aimed at discerning the widespread opinion or sentiment on any given topic, idea, product or person. The scores function helps us use the group of words you're interested in analyzing in a quantifiable way, identifying and categorizing the opinions (often numerically), especially in order to determine whether the someones attitude towards a particular topic, product, etc., is positive (greater than zero) , negative (less than zero), or neutral (zero).  

I've been looking around for a good, functional code that would help repeat what Herman did in his video, because I came across some problems. It wasn't easy, but after playing around with the code and doing a lot of searches (because I still consider myself a beginner with R), I successfully analysed the Twitter data. You should watch the video to see where the changes were made.

Here is my R code for the Sentiment Analysis:

Importing the data

The code provided in the video is outdated and thus will not work because Twitter changed the way a user can access its API. Now you're going to need authentication in order to grab tweets. In order to get that authentication, you're going to need to create a Twitter app (it's pretty easy). The authentication comes in the form of keys and tokens. Luckily, the twitteR package has been updated to accommodate the change.
 library(twitteR); library(plyr)

 setup_twitter_oauth("API key", "API secret", "Access Token", "Access Token")     
Like the example in the video, we will search for  '#abortion', but I instead of searching for 1500 tweets, I will search for 200 because (1) R can take a while just to grab 30 tweets, and (2) I don't feel like waiting too long to do this; I just want to show that the code works.
tweets = searchTwitter("abortion", n=200) 

length(tweets) 

The Algorithm

The next thing to do, if you havent already, is to download the documents that Michael mentioned in the video. I did this, and it turned out to be messy. I don't know why, but when I went to the links, the text files I downloaded had an html format to it. Incredibly complicated the process. Instead, I used this link provided by Bing Liu, which gives you a rar file containing the two files you need. These files are just lists of positive (positive-words.txt) and negative (negative-words.txt) words. We will need them to match the list of tweets with the words from both files.

To make this easier to call in R, try and save or place them in the same folder that placed your R directory. For instance, you can just set your desktop to be the directory (or the place R expects to easily call files from), and then you wont have to worry about about using the exact file's location, because R already knows where the file is (your directory).

Now, the meaty part of this tutorial is the score.sentiment() function. This was what actually gave me the most problems, because if this isn't right, your analysis (for this tutorial) isn't going anywhere. I've checked with Michael's attempt (the code I saw circling around the internet the most), and I've tried Silvia Planella's updated version of the code; both times I encountered errors, and they were incredibly frustrating. With Michael's code, I got confused because there were no words I wished to exclude, but the function appeared to have required that (with the 'exc.words' input of the function), and at the same time, Michael didn't need to provide any, while R wouldn't let me continue unless I did. Planella's version of the code removed the 'exc.words' part of the function, which eleminates that problem, but the code never accounted for characters that R cannot recognized.

For instance, here's one of the tweet messages I had extracted: 'Awarded €2,000 & incited change. 2 yrs later #abortion was legalized in Portugal í ½í¹Œ @Vesselthefilm @BostonDoulas #reprojustice'. When I try to process the messages in the score.sentiment() function, the entire process would provide an error that looked like this:
 Error during wrapup: invalid input 'Awarded €2,000 & incited change. 2 yrs later #abortion was legalized in Portugal í ½í¹Œ @Vesselthefilm @BostonDoulas #reprojustice' in 'utf8towcs'   

If you're not used to this kind of thing, then I bet you're gonna look at it like I did...heck, maybe experts have problems with this from time to time.


The problem is some characters are not valid, so if you come across this problem, you got to find a way to exclude the invalid characters from the analysis, either from within R or before importing the files for processing.

Thankfully, I found someone with valuable experience for this situation: Gaston Sanchez. From his blog post, I learned that the error I encountered occurred when these unrecognized characters are passing through the tolower() function, which was used in the sentiment score function, so I updated the code by adding a try-catch function to account for these potential errors; problem fixed.
 score.sentiment = function(sentences, pos.words, neg.words, .progress='none')
{
  require(plyr)
  require(stringr)
  
  # we got a vector of sentences. plyr will handle a list
  # or a vector as an "l" for us
  # we want a simple array of scores back, so we use
  # "l" + "a" + "ply" = "laply":
  scores = laply(sentences, function(sentence, pos.words, neg.words) {
    
    # clean up sentences with R's regex-driven global substitute, gsub():
    sentence = gsub('[[:punct:]]', '', sentence)
    sentence = gsub('[[:cntrl:]]', '', sentence)
    sentence = gsub('\\d+', '', sentence)
    
    # convert to lower case:
    # Instead of a regular tolower function, make a try-catch function
    tryTolower = function(sentence)
    {
      # create missing value
      # this is where the returned value will be
      y = NA
      # tryCatch error
      try_error = tryCatch(tolower(sentence), error = function(e) e)
      # if not an error
      if (!inherits(try_error, "error"))
        y = tolower(sentence)
      return(y)
    }
    sentence = tryTolower(sentence)
    
    # split into words. str_split is in the stringr package
    word.list = str_split(sentence, '\\s+')
    # sometimes a list() is one level of hierarchy too much
    words = unlist(word.list)
    
    # compare our words to the dictionaries of positive & negative terms
    pos.matches = match(words, pos.words)
    neg.matches = match(words, neg.words)
    
    # match() returns the position of the matched term or NA
    # we just want a TRUE/FALSE:
    pos.matches = !is.na(pos.matches)
    neg.matches = !is.na(neg.matches)
    
    # and conveniently enough, TRUE/FALSE will be treated as 1/0 by sum():
    score = sum(pos.matches) - sum(neg.matches)
    
    return(score)
  }, pos.words, neg.words, .progress=.progress )
  
  scores.df = data.frame(score=scores, text=sentences)
  return(scores.df)
} 
The score.sentiment() function returns tabular data with multiple columns and multiple rows. In R, the data.frame is the workhorse for such spreadsheet-like data.

Subsequent Analyses

After you use the function I provided, you should be able to get similar results and the same functionality as it is in the video. Cheers.
 analysis = score.sentiment(tweets.text, pos, neg, .progress="text")    
> table(analysis$score)

-3 -2 -1  0  1  2  3 
 1  5 86 54 31 21  2 
> median(analysis$score)
[1] 0
> mean(analysis$score)
[1] -0.1
> hist(analysis$score)

I think there is more that can be done with the sentiment analysis, but right now this is good enough. I checked out this Villanova University paper and it provided a neat template for a sentiment analysis function. Maybe I will be able to contribute to this someday.

Learn More:


Read More »

Sunday, March 15, 2015

Through an economic lens: the nexus between migration and the human trafficking industry

Human Trafficking can easily be confused with migrant smuggling, but they're not the same; if anything, the difference is important. Migrant smuggling is a commercial service that normally occurs with the consent of migrants, and from illegal migration, which does not typically involve any forms of exploitation, whereas human trafficking is a situation in which an individual travelling abroad was locked and forced to work for no or little pay via means of coercion.

However, because they aren't the same doesn't mean there isn't a close link between the two topics. Yes, factors such as legislation, law enforcement, ethnic discrimination, corruption, and insufficient education are widely considered significant drivers of human trafficking, but leaving out migration in that analysis may prove detrimental to the counter-trafficking efforts. This is because one of the ways millions of people get exploited is through migration efforts, especially if they live in less developed countries. Their willingness to depart and accept risks in the migration process makes them prime candidates to be exploited by criminal agents, who benefit from the enormous information asymmetries involved.

Socioeconomic conditions 

The economic situation of people in these poorer regions of the world (like Mauritania, certain areas in ThailandPakistan, etc.) is a fundamental breeding ground for trafficking and exploitation, which may end up pushing vulnerable people to emigrate and seek better opportunities abroad. We're talking about a supply of potential victims and criminal actors fostered from suffering high unemployment, low wages and poor institutions. These factors have fostered the emergence of shadow industries offering migration services such as border crossings and illegal work abroad, such as domestic house maids, prostitutes, etc. For residents of low- and even middle-income countries, the large potential gains from migration, combined with network effects have generated an unprecedented push for legal migration to richer countries. However, with most middle and high-income country labor markets open primarily to the domestics, there are very limited legal working opportunities available for the foreign workers. So while, for them, there are less opportunities in the more desirable sectors, which tend to be reserved for people with better education; the demand for prostitutes and cheap manual workers in both high-income and low-income countries remain constant and high.

People as "commodities"

Slavery is a life course event: when one is enslaved, there is no fundamental endpoint for when it might end for him or her. The only way to guarantee when slavery ends for a person is determined by his or her lifespan, and to criminal actors, that lifespan is tied to the slave's value. As one researcher put it, “people are a good commodity as they do not easily perish, but they can be transported over long distances and can be re-used and re-sold”. This is consistent with the thought that for more people than we give credit, a slave can be a victim of not just one, but many kinds of trafficking.

Incentive to Shut up

What tends to put the victims in a trap is when their environments make it hard for them to escape. Sometimes the government or police in the area are so corrupt, a victim can escape and be sent back to the place he or she fled from, and these kinds of dilemmas can discourage victims from denouncing their traffickers. For victims illegally residing in other countries, their dilemma , since doing so puts them at great risk of getting deported and the potential legal consequences with authorities in their home countries. In economic terms, they tend to find the costs of ratting on the traffickers greater than the benefits.

Labor Supply: mostly voluntary

This is not the case for all, but most of the victims of trafficking depart to another country through voluntary means. Based on scarce scholarly input, two of these voluntary examples were modeled. These models are consistent with with Bales' writings on ways people can get trafficked these days.

One model describes the interaction between trafficking and migration, where potential victims pay a smuggler to help them cross the borders. In this situation where once migrants depart, it depends on the smuggler’s decision and the profitability of exploitation whether the potential victim end up being trafficked or not, which might have something to say about the kinds of persons that tend to get trafficked in a given country. A different kind of model looks at illegal migration markets with debt and labor contracts. Most migrants cannot pay for migration costs in advance, so criminal intermediaries and smugglers tend to offer loans to potential victims, which they have to pay back once they work in the destination country. The enforcement of these contracts occur in the criminal sectors, which is reasonable: these contracts in themselves aren't legal.

In speculation, this can be really bad for potential victims, because if the lender provides money for them to travel, chances are they will supply the migrant a job, which may likely be within the lender's network, where the criminal actor can monitor and control the victim's movements. Based on the cases in Brazil and in Pakistan, there is a good reason to think that a slave won't get paid enough money to pay off the debt in a reasonable period of time, assuming he or she gets paid at all.

Note #1: Human trafficking and migration pretty much go hand in hand, depending on how you see it. There is indeed a thin line between the two: that thin line may be a matter of whether the migrant ends up a victim to slavery or not.

A cost-minimizing effort

In the business side of human trafficking, firms hire traffickers to smuggle in people for the sake of lowering labor costs. They never expected to pay the victims a lot of money in the first place, otherwise they might as well pay for more "skilled" workers. A scholarly resource modeled this graph depicting demand for Human Trafficking victims. The limit paid for slaves is represented by the dotted part of the demand curve.
(Graph: Demand for Human Trafficking, Wheaton et al, 2010)
Hypothetically speaking, the range of hourly pay would be somewhere in the range 0 ≤ k < q, where k is the amount of money paid to the slave, and q is the lowest amount an employer would pay a regular worker. This is consistent with the viable price region labeled on the graph, where P-high can be seen as the final price before the employer would prefer to pay for regular, more "skilled" workers,  again denoted by q.

A monopolistic-competitive look

Like a monopolistic competitive industry, the market for human trafficking victims is characterized by

  • many buyers and sellers
  • differentiated products (the laborers at various age, gender, and ethnic combinations)
  • easy entry and exit
The profits made in the human trafficking industry are rather paramount: about $32 billion in illicit profits a year is generated for traffickers. This attracts other firms or small-networked entrepreneurs to get into the mold and make profits; otherwise, they leave. For those who enter, they are able to at least control some of the price given the diverse group of people they have to target from within their communities. 

Note #2: The models mentioned provide a glimpse of how things are seen on the business side to human trafficking, and it is heavily fueled by a combination of desired lower labor costs, hopes of a better life, and immense scarcity (in relation to other regions/countries). 



Sources

  • Tamura. 2007. "Migrant Smuggling." IIIS Discussion Paper No. 207, Institute for International Integration Studies.
  • Mahmoud & Trebesch. 2009. "The Economic Drivers of Human Trafficking: Micro-Evidence from Five Eastern European Countries." Kiel Institute for the World Economy.
  • Friebel and Guriev. 2012. "Human Smuggling". IZA Discussion Paper No. 6350. The Institute for the Study of Labor. 
  • Bales, Kevin. 2012. "Disposable People: New Slavery in the Global Economy." University of California Press. 
  • Wheaton et al. 2012. "Economics of Human Trafficking.", International Migration Vol. 48, IOM. 

Learn More



Read More »

Monday, March 9, 2015

Robert Kosara on the value of illustrating numbers

Robert Kosara shared some valuable insight on the way numbers are illustrated when using visualizations. To read the full post, click here.
Some important points from the post:


Showing data isn’t always about trying to convey an insight:

It can also be a tool to communicate a fact, an amount, or an issue beyond just the sheer numbers. Although data illustration is poorly understood, it can be very powerful.

All data is not created equal:

You can turn any kind of data into a bar chart and get some sort of insight out of it. However, Kosara thinks some data just requires a bit more care and thought – not because of its structure, but because of what it represents. Kosara puts it nicely:
"When it comes to data about people, perhaps the approach needs to be a bit more thoughtful and respectful. Looking at data about homeless people, do we really need yet another goddamn bar chart? Is there not a more appropriate way to look at this data? Or think of the design process and thought that went into the 9/11 Memorial. This isn’t the phone book, these are all individuals who died in horrendous ways."

Getting the sense of the "number":

While numbers always invite comparison, there is a point at which comparison becomes distracting and an excuse to minimize the significance of the number. Kosara argues that we spend too much time comparing numbers instead of appreciating them. He uses the examples of gun and drone strike deaths, claiming that when try to derive the significance of, lets say, 2,300 deaths via guns, by comparing them to some other cause of death, then we have already missed the point; and I agree with him. The goal of these numbers is punch you in the gut, and make you feel some kind of way.

I hope to take these lessons to heart on my analytics journey. I wouldn't want to be obsessed with digits enough to be desensitized by the weight of what that number reflects. This should not only keep me aware, but guide my data visualization strategies as well.
Read More »

Sunday, March 8, 2015

Understand the different aspects of Human Trafficking


From Human Trafficking.org:
Sex Trafficking: Victims of sex trafficking are often found working in establishments that offer commercial sex acts, i.e. brothels, strip clubs, pornography production houses. Such establishments may operate under the guise of:
  • Massage parlors
  • Escort services
  • Adult bookstores
  • Modeling studios
  • Bars/strip clubs
Not every person working in these establishments will have technically been trafficked. It would be necessary for trained authorities or service providers to interview each person individually to determine trafficking. 
Labor Trafficking: People forced into indentured servitude can be found in:
  • Sweatshops (where abusive labor standards are present)
  • Commercial agricultural situations (fields, processing plants, canneries)
  • Domestic situations (maids, nannies)
  • Construction sites (particularly if public access is denied)
  • Restaurant and custodial work
Another kind of labor trafficking includes child soldiers. In over 40 countries across the globe, thousands of children are being forced or tricked into becoming soldiers. It is most known to be present in conflict-riddled African countries like Somalia, Sierra Leone, Uganda, and Sudan, but there are also known instances in Asian countries, like Myanmar (formerly known as Burma), which was believed to have had the highest number of child soldiers at one point.
How Do People Get Trapped Into Sex or Labor Trafficking? 
No one volunteers to be exploited. Traffickers frequently recruit people through fraudulent advertisements promising legitimate jobs as hostesses, domestics, or work in the agricultural industry. Trafficking victims of all kinds come from rural, suburban, and urban settings. There are signs when commercial establishments are holding people against their will.
Human Trafficking isn't just limited to sex and labor. Some kinds of human trafficking occur for the sake of transferring a victim's organs. Organ trafficking (for kidneys in particular) is a rapidly growing field of criminal activity. Kidney's are a high demand commodity, and these are the only major organs that can be wholly transplanted with relatively few risks to the life of the donor.

References:




Other sources you can read from:


Read More »

The Well-being of a Human Trafficking victim


Victims of trafficking in humans can be found in a variety of situations, so I will provide a list of some general indicators. That way you can play a role in identifying such victims.

Economic

  • Receive little or no payment
  • Have no access to their earnings
  • Be unable to negotiate working conditions
  • Be unable to leave their work environment
  • No days off
  • Work excessively long hours over long periods
  • Be under the perception that they are bonded by debt
  • Have had the fees for their transport to the country of destination paid for by facilitators, whom they must payback by working or providing services in the destination
  • Be forced to work under certain conditions

Social

  • Be subjected to violence or threats of violence against themselves or against their family members and loved ones
  • Be unable to communicate freely with others
  • They often have acted on the basis of false promises
  • Believe that they must work against their will
  • Be threatened with being handed over to the authorities
  • Be disciplined through punishment
  • Be in a situation of dependence
  • Have limited or no social interaction

Health (mental and physical) 

  • Show signs that their movements are being controlled
  • Allow others to speak for them when addressed directly
  • No access to medical care
  • Suffer injuries that appear to be the result of an assault
  • Show fear, anxiety, or timid behavior
  • Suffer injuries or impairments typical of certain jobs or control measures
  • Act as if they were instructed by someone else
  • Be afraid of revealing their immigration status
  • Distrustful of the authorities
  • Suffer injuries that appear to be the result of the application of control measures

Living Conditions

  • Feel that they cannot leave
  • Be found in or connected to a type of location likely to be used for exploiting people
  • Not know their home or work address
  • Live in poor or substandard accommodations
  • Come from a place known to be a source of human trafficking
  • Have limited contact with their families or with people outside of their immediate environment
  • Be unfamiliar with the local language.

Other

  • Claims of just visiting and inability to clarify where he/she is staying/address
  • Lack of knowledge of whereabouts and/or do not know what city he/she is in
  • Little to no education
  • Loss of sense of time
  • Has numerous inconsistencies in his/her story
  • Have false identity or travel documents
  • Not be in possession of their passports or other travel or identity documents, as those documents are being held by someone else.

This list is not exhaustive and represents only a selection of possible indicators. Also, the red flags in this list may not be present in all trafficking cases and are not cumulative. Despite the presence or absence of any of the indicators, neither proves nor disproves that human trafficking is taking place, but their presence should lead to some investigation.
Read More »

Wednesday, March 4, 2015

How King v. Burwell can negate the current Healthcare landscape

It seems there's always something about Obamacare (formerly known as the Affordable Healthcare Act) that attracts detractors. This time around, the fuss is over a matter of mere words. 

An overview in brief:

King v. Burwell [formerly known as King v. Sebelius] challenges an IRS regulation imposed under the Affordable Care Act that allows subsidies on both state and federally-established health insurance exchanges. The belief, on King's side, is that the IRS regulation violates the plain language of the law enacted by Congress, which gave states the choice to either set up such exchanges themselves or stay out of the program.

An overview in videos:

What this means:

If the court rules in favor of King, then that basically negates all hope for eligibility of subsidies to people in the states without established state exchanges.
Whether it will negatively affect the people in states with already established state exchanges remains to be seen. From what I know, it doesn't seem mandatory for the states with exchanges to get rid of them if the ruling goes in favor of King, but with the mandate null and void, it doesn't seem there's much big obstacles for the state lawmakers to hurdle if they do, besides public unrest.

Speaking of public unrest, it seems there is going to be a lot of angry people over this. Those who don't have access to Obamacare anyway would essentially be slipping back into the dark ages of the old healthcare system, and there are people in the states with exchanges who can potentially lose their healthcare if the state decides to denounce exchanges (something I don't find likely). Either way, that is still millions of people who may lose their healthcare.

And with the mandate gone, one of the ACAs main goals, reducing healthcare costs, gets sacked in the process. Hypothetically speaking, the mandate was what we were supposed to bank on to reduce healthcare costs for the country. Before the ACA, the healthcare system was plagued with high costs due to the large number of uninsured people. For the consumers, it was normal for coverage to be denied resulting from preexisting conditions. Moreover, the healthy would wait until they get sick and buy insurance, indicating the existence of an adverse selection problem. Adverse selection in medical insurance markets occurs when people purchase insurance to cover known conditions. Before the mandate was a reality, the costs go up for everyone because the sick were left to buy the insurance, and as they used more insurance and filed more claims, premium rates went up, which also meant higher taxes to pay for the uninsured when they ended up needing emergency medical care. This mandate eliminates these issue, so if about 37 states cant (or won't) access that mandate, then we may end up seeing the ACA running half-fast (or half-assed).
Read More »

Blogger: How to Customize Status Bar

The status bar of Blogger or Blogspot is that rectangle shaped figure shown at the top of the ticket when we access the labels or do a search. By default, it has defined styles for the border, background and font, but it's neutral appearance is not always appropriate for the style you want on your blog. If you have a transparent background, for instance, the default status message might be hard to see once you put up a lighter wallpaper (usually an issue for the Awesome Blogger themes).

Customizing the status bar look

To customize this bar, it is necessary to add about 3 or 4 classes in the css section of the template:
  • status-msg-wrap (optional): the parent container of the bar is the place to define their location with respect to the inputs. 
  • status-msg-body : Class responsible for defining the message style; changes font size and font color. 
  • status-msg-border : Class that defines the edge, and changes the colors of that edge. 
  • status-msg-bg : Class that defines the background color of the message bar.
I dont think its very necessary to accompany these classes with the top selector "#main" to overwrite the default values, but it is a nice to have it. It at least makes certain for sure that the code will work, but don't be surprised if there are no problems otherwise.

For you to implement these 3 or 4 classes, go to the Template section in your blog's Design page and click on Edit HTML.

Dashboard > Template > Edit HTML


All that HTML code is your Blog template, and it is up to you to make sure you don't do enough to screw up any necessary functionality in your blog, so before you begin this, do yourself a favor:

back up your template!


Copy and paste it into some text editor you got somewhere. That way you don't have to worry about losing everything you worked to add to your blog's template.

Okay, so now you're at the HTML page, which should look like this.

Now I want you to click anywhere in the code page (just to make sure your computer knows you're referring to the code box and not the actual webpage), and do a search (CTL+F). Search for ]]> </ b: skin> and once you do, you are to take the code to change the status bar and place it above (or before) the ]]> </ b: skin>.

Examples

(The CSS code goes before ]]> </ b: skin>)

With all four classes...
       
#main .status-msg-wrap {
width: 90%;
padding: 5px;
}

#main .status-msg-body {
font-size: 80%;
text-align: left;
padding: 5px 5px 5px 30px;
width: auto;
}

#main .status-msg-border {
border: 1px solid # a19a36;
opacity: 1;
}

#main .status-msg-bg {
background: # FFF9B3 center left no-repeat;
opacity: 1;
}     
 
That will turn out to look like this.

  • .status-msg-body  font-size : alters the size of the text in the status message
  • .status-msg-body  text-align: sets the text to either the (center, left, right) of the status message box
  • .status-msg-body  width: deals with the width of the status message box
  • .status-msg-border  opacity: between 0 and 1, the closer to 1, the more visible the status message background is.
The way I did it just shows the designated label (I named the label "ECON") name so I have a quick understanding of what section I'm in.
       
/* Label Status Message
———————————————————————————————————————–*/
.status-msg-body {    /* This changes the font and font color  */
font: 100% Century Gothic;
color: #fff;
text-transform: uppercase;
font-weight: bold;
}

.status-msg-bg {    /* This changes the background color of massage bar */
background: #000000;
opacity: 1;
}

.status-msg-border {   /* This changes the color of the border */
border: 1px #e9d8d9;
opacity:0.7;
}        
       
 
That will look like this .



Changing the Status bar message

To add text to your label header, return to Edit HTML, then use Ctrl+F / Command F to find this code:

<data:navMessage/>


There may be about two of these codes, and in fact, it may just look like this, and in that case, just get rid of the first instance of the code.
  <div class='status-msg-wrap'>
    <div class='status-msg-body'>
      <data:navMessage/> <!--THIS CODE, GET RID OF IT-->
    </div>
    <div class='status-msg-border'>
      <div class='status-msg-bg'>
        <div class='status-msg-hidden'><data:navMessage/></div>
      </div>
    </div>
  </div>
  <div style='clear: both;'/>
  </b:if>        

Type the message you wish to appear on your label header, such as:

You are now viewing my rants on:  <data:blog.searchLabel/>


Where <data:blog.searchLabel/> is the code that will reflect the link to your label (so if one of your labels is "Help" or "World News", this code will directly correspond to that).

Now, your status bar should instead say that, or if you want to just show the label name, just use the <data:blog.searchLabel/> code by itself in place of the first <data:navMessage/> and click save. It should look like this.
 <div class='status-msg-wrap'>
    <div class='status-msg-body'>
      <data:blog.searchLabel/>
    </div>
    <div class='status-msg-border'>
      <div class='status-msg-bg'>
        <div class='status-msg-hidden'><data:navMessage/></div>
      </div>
    </div>
  </div>
  <div style='clear: both;'/>
  </b:if>       

Changing the label colors 

Return to Edit HTML, then use Ctrl+F / Command F to find the same code we have been working with:

<data:blog.searchLabel/>


And to change the message color, font, or style, simply add the needed font tags.

<font color=”red”>You are now viewing my rants on: </ font>


Afterwards, just click Save. Your new label header should now appear whenever you click on any of your post labels.

Conclusion

The Blogger status bar structure is a bit complex, maybe poorly organized, so to customize this part properly, much care should be taken to overwrite all default styles.

Note: Strangely the status bar message repeated twice, only one of them has attributes for no show, apparently blogger team made the various elements of your templates steam.

Note: This post was heavily influenced by someone else's post. I felt there was a need to add a bit more pieces of information, so I adapted it, but you are more than free to check out the original source.
Read More »