High resolution graphics with R

For most purposes PDF or other vector graphic formats such as windows metafile and SVG work just fine. However, if I plot lots of points, say 100k, then those files can get quite large and bitmap formats like PNG can be the better option. I just have to be mindful of the resolution.

As an example I create the following plot:
x <- rnorm(100000)
plot(x, main="100,000 points", col=adjustcolor("black", alpha=0.2))
Saving the plot as a PDF creates a 5.2 MB big file on my computer, while the PNG output is only 62 KB instead. Of course, the PNG doesn't look as crisp as the PDF file.
png("100kPoints72dpi.png", units = "px", width=400, height=400)
plot(x, main="100,000 points", col=adjustcolor("black", alpha=0.2))

Hence, I increase the resolution to 150 dots per pixel.
png("100kHighRes150dpi.png", units="px", width=400, height=400, res=150)
plot(x, main="100,000 points", col=adjustcolor("black", alpha=0.2))

This looks a bit odd. The file size is only 29 KB but the annotations look too big. Well, the file has only 400 x 400 pixels and the size of a pixel is fixed. Thus, I have to provide more pixels, or in other words increase the plot size. Doubling the width and height as I double the resolution makes sense.
png("100kHighRes150dpi2.png", units="px", width=800, height=800, res=150)
plot(x, main="100,000 points", col=adjustcolor("black", alpha=0.2))

Next I increase the resolution further to 300 dpi and the graphic size to 1600 x 1600 pixels. The file is still very crisp. Of course the file size increased. Now it is 654 KB in size, yet sill only about 1/8 of the PDF and I can embed it in LaTeX as well.
png("100kHighRes300dpi.png", units="px", width=1600, height=1600, res=300)
plot(x, main="100,000 points", col=adjustcolor("black", alpha=0.2))

Note, you can click on the charts to access the original files of this post.

"The insurance company came out and looked at my car. Doesn't that commit them to paying the claim?"

No. Insurers are required to investigate claims, but the fact that they start an investigation doesn't obligate them to pay a claim that they wouldn't otherwise pay. Once the facts are gathered and reviewed, the insurer can then make a coverage decision.

That said, if you feel your claim has been wrongly denied, is delayed, isn't fair, etc., our consumer advocacy staff may be able to help you. (We're the state agency that regulates insurance in Washington state.) Email us at AskMike@oic.wa.gov or call us at 1-800-562-6900.

Not in Washington state? Here's a handy map to help you contact your own state's insurance regulator.

Why does my insurer ask such tough questions about my claim?

We get this question a lot. The insurance industry experiences millions of dollars of claims regularly, year after year. Many of the claims are legitimate, but unfortunately, many involve fraud.
Whether or not a claim is legitimate or fraudulent, it is important that insurance companies perform complete investigations and gather all supportive documentation to be able to evaluate a claim.
Of course, the claim process is not a fun thing to experience, but it is necessary that you cooperate with the insurer to help facilitate your claim. Expect them to want supporting documentation and to ask questions - it may take a bit of time. But, after you've answered their questions and provided the necessary information, you should expect a timely decision and a clear explanation of their decision. If you don't that you've been treated fairly, call us at 1-800-562-6900 or file a complaint. Maybe we can help!

Review: Kölner R Meeting 18 October 2013

The Cologne R user group met last Friday for two talks on split apply combine in R and XLConnect by Bernd Weiß and Günter Faes respectively, before the usual Schnitzel and Kölsch at the Lux.

Split apply combine in R

The apply family of functions in R is incredible powerful, yet for newcomers often somewhat mysterious. Thus, Bernd gave an overview of the different apply functions and their cousins. The various functions differ in their object inputs, e.g. vectors, arrays, data frames or lists, and their outputs. Other related functions are by, aggregate and ave. While functions like aggregate reduce the output size, others like ave will return as many rows as the input object and repeat the results where necessary.

Alternatively to the base R function Bernd touched also on the **ply functions of the plyr package. The function names are certainly easier to remember, but their syntax can be a little awkward (.()). Bernd's slides, in German, are already available from our Meetup site.


When dealing with data stored in spreadsheets most member of the group rely on read.csv and write.csv in R. However, if you have a spreadsheet with multiple tabs and formatted numbers, read.csv becomes clumsy, as you would have to save each tab without any formatting in separate files.

Günter presented the XLConnect as an alternative to read.csv or indeed RODBC for reading spreadsheet data. It uses the Apache POI API as the underlying interface. XLConnect requires a Java runtime environment on your computer, but no installation of Excel. That makes it a true platform independent solution to exchange data with spreadsheets and R. Not only can you read defined rows and columns from Excel into R, or indeed named ranges, but in the same way data can be stored in Excel files again and to top it all - also graphic output from R.

Next Kölner R meeting

The next meeting is scheduled for 13 December 2013. A discussion of the data.table package is already on the agenda.

Please get in touch if you would like to present and share your experience, or indeed if you have a request for a topic you would like to hear more about. For more details see also our Meetup page.

Thanks again to Bernd Weiß for hosting the event and Revolution Analytics for their sponsorship.

Having trouble reaching the Exchange's call center?

We know Washington's Exchange, www.wahealthplanfinder.org is still experiencing high call volumes at most times of the day. If you need help getting started, consider calling a navigator or an insurance broker. You can find both in your area by entering your zip code. Here's the info. for finding a navigator and the broker information.

"I've invented a new medical treatment. How can I get insurers to cover this?"

Our consumer hotline gets this question periodically. Someone will have come up with a new way of treating some ailment, only to find that insurance companies don't want to cover it.

Insurance companies are far more likely to cover a treatment is it's "evidence-based. Typically, a treatment is deemed evidence-based after extensive clinical trials, for which the inventor (or inventor's company, actually) usually pays. In the scientific community, evidence-based treatments are considered more reliable, and therefor a better value for insurance companies' money -- and more likely to lead to success for the patient.

That said, insurance companies can pay for any treatment, so there's nothing stopping them from covering a treatment that's not evidence-based. However, with many health conditions, there are already numerous treatments available.

If you're a patient, and your insurer is refusing to pay for a particular treatment that you think would be effective, see our "How to appeal a health insurance denial" guide. You can win an appeal, but it takes some work.

Also, here in Washington state, the health plans we regulate -- which are about 37 percent of them -- must, by law, must include access to every type of licensed medical provider. Meaning that if you want to see a naturopathic physician, chiropractor, physician, acupuncturist, etc. for treatment, the choice is yours, so long as the treatment is within the scope of their practice. The law doesn't change what health conditions are covered by your plan, but it gives you more choice in who -- i.e. which kind of provider -- will treat you.

The New Normal

<$BlogPageTitle$> <$BlogItemBody$>

Medicare open enrollment started this week and ends Dec. 7

<$BlogPageTitle$> <$BlogItemBody$>

Job seekers - We're looking for a legislative liaison and a policy/rules manager

<$BlogPageTitle$> <$BlogItemBody$>

See most recent earthquakes in our area - are you ready for the big one?

We're getting ready for tomorrow's Great ShakeOut Earthquake Drill by cleaning out all the stuff under our desk - how about you? It's been a long time since the Nisqually Quake, but if you lived in Washington state then, you probably remember where you were and what it felt like. 
Some of us here in Olympia - only miles from the epicenter - heard what sounded like a freight train. Others saw the ground move like water. Are you ready for the next one? 
Check out the earthquake tracker on KIRO's mynorthwest.com. It'll show you the most recent quake, how big it was and where it occurred.  

And don't forget about earthquake insurance - here's what you need to know.

Next Kölner R User Meeting: 18 Oktober 2013

Quick reminder: The next Cologne R user group meeting is scheduled for this Friday, 18 October 2013. We will discuss and hear about the apply family of functions and the XLConnect package. Further details and the agenda are available on our KölnRUG Meetup site. Please sign up if you would like to come along. Notes from past meetings are available here.

Thanks to Revolution Analytics, who sponsors the Cologne R user group as part of their vector programme.

How to report insurance fraud in Washington state

Our agency -- Washington state's insurance regulator -- handles a wide variety of complaints about insurance fraud by individuals and by businesses.

To report insurance fraud or scams, please see our online reporting form.

We also offer tips to avoid insurance scams, starting with the old-but-true advice that if it sounds too good to be true, it probably is.

We also have some tips on how to identify and report Medicare fraud and abuse, such as being billed for services you didn't receive.

I know the new health subsidies are based on your household income, but how do they define 'household'?

“Household” only includes you, your spouse, and anyone you can legally claim as a dependent on your tax return.

 It generally wouldn’t include a non-marital relationship (such as a boyfriend or girlfriend), except under very limited circumstances.

To get more details, see page 16 of the IRS instructions for filling out Form 1040 or call the IRS (after the government shutdown ends) at 1-800-829-1040.

When your insurance renews, remember to look at the statement

When you get a new insurance policy or your current policy renews, be sure to review the statement. You need to be sure that you're getting the type and level of coverage you asked for. 

Most people simply file away the information -- or toss it. But take a few minutes to look it over first. You really don't want to find out after the fact that a) you were paying for coverage you didn't want or need, or b) worse, that you didn't have coverage for something important.

If you see something that doesn't look correct, contact your agent or insurer immediately, before a loss occurs. If you wait until afterward, you'll likely be stuck with whatever coverage was in force at the time of the loss.

It's also a good idea to periodically review your coverage with your agent or insurer. You may want to add or eliminate coverage as changes occur in your life situation.

Why models need a certain culture to flourish

About half a year ago Ian Branagan, Chief Risk Officer of Renaissance Re - a Bermudian reinsurance company with a focus on property catastrophe insurance, gave a talk about the usage of models in risk management and how they evolved over the last twenty years. Ian's presentation, titled with the famous quote of George E.P. Box: "All models are wrong, but some are useful", was part of the lunch time lecture series of talks at Lloyd's, organised by the Insurance Institute of London.

I re-discovered the talk online over the weekend and found it most enlightening again.

So, what makes models useful? And here I mean models that estimate extreme outcomes / percentiles. Three factors are critical, according to Ian, to embed models successfully in risk management and decision making processes.
  1. Need - A clear defined need for the model.
  2. Capabilities - The skills and resources to build and maintain the model.
  3. Culture - An organisational culture that embraces, understands and challenges the model.
The need, if not driven internally, is often imposed by external requirements, such as regulation, e.g. banks and insurers have to use models to estimate the risk of insolvency in many countries. Building capabilities can largely be achieved by investing in people, technology and data. However, the last factor culture, so Ian, is often the most challenging one. Changing business processes, particularly in decision making at senior level requires people to change.

Where in the past senior management may have relied on advisors' expert judgement to guide them in their decision makings, they have to use models in a similar way now as well. I suppose, in the same way as it takes time and effort to build effective relationships with people, it is true for models as well. And equally, decisions should never rely purely on either other people's opinion or indeed model output. As Ian put it, outsourcing all modelling/thinking, and with that the decision making to vendors of models, such as catastrophe modelling companies or rating agencies, who both aim to provide probabilities for extreme events (catastrophes and companies failures) may be sufficient to tick a risk management box, but can ultimately put the company at risk, if model assumptions and limitations are not well understood.

Perhaps we are at the dawn of another enlightenment? Recall Kant's first sentence of his essay What is enlightenment?: "Enlightenment is man's emergence from his self-incurred immaturity." Indeed, it doesn't matter if we use experts' opinions or the output of models, relying blindly on them is dangerous and foolish. Don't stop thinking for yourself. Be critical! Remember, all models are wrong, but some are useful.

Plotting Your Escape From The PPACA

William was damned near ecstatic. My client had a right to be. William is a 57 year old self-employed Republican pragmatist. He is also very unhealthy. There are no imminent threats. He just suffers from the kinds of things that causes health insurance companies to run away. William’s current health insurance, a $5,000 deductible HSA qualified contract, is $1,055 per month. On January 1, 2014 his premium plummets to $404.

William is now a huge fan of the Patient Protection and Affordable Care Act (PPACA). And if you, like Bill, are paying a lot of money for your health insurance due to your significant health problems, then the new law may save you a lot of money, too. Today’s blog is not for you.

Today’s blog is for those Americans who are reasonably healthy, do not need maternity coverage, and have an income above 400% of the federal poverty level. This is also a post for those people who will not qualify for a federal subsidy for a number of other reasons. The following will actually be relevant for a lot more people than you might think.
Today’s blog post includes numbers. Lots and lots of numbers. Stay with me. This is your money.

The exchanges opened October 1st. There have been, predictably, significant computer issues that will be resolved in time. Some of our insurers are still trying to get their policies and applications approved. I have been advising my clients to ignore the new system until November 1st.

I finally received Medical Mutual of Ohio’s 2014 rates. We don’t have applications, just rates. Here is how the PPACA affects a healthy 58 year old who happens to be fond of a good cigar (ME!).

Current Policy - $5,000 deductible HSA qualified contract - $310 per month

New 2014 Policy - $6,000 deductible HSA qualified contract - $633 per month

If you will bear with me, I will give you a more complete look at some real numbers. The following is a Medical Mutual of Ohio policy, $6,000 HSA qualified contract, for a non-smoker. The 2013 rates assume the insured is healthy. We no longer care in 2014 as we begin to utilize community rating.

                     2013                                                                        2014
            Male          Female                                                  Male and Female
22     $ 55.21         $ 75.43                                                        $166.75
42        92.68          135.67                                                          219.62
62      244.92          254.09                                                          476.20

Community rating is great if you are the sickest guy on your street.
All of these policies, new in 2013 and new for 2014, cover preventive care at 100%. The 2014 policies also cover maternity the same as any other medical condition. But if you don’t have a serious pre-existing condition and you don’t need maternity, you don’t need one of the new 2014 policies.

How do you escape the PPACA if it isn’t going to help you? Get coverage now! A policy purchased now, effective now, eludes the PPACA till the end of 2014. What will we do a year from now? I don’t know, but I would rather save $3,600 over the next year and see what develops.

The Department of Health and Human Services (HHS) has been forced to create this on the fly. Let’s give them an extra year to get this right. If you allow yourself to be victimized by the PPACA, it is your own damn fault.



Hole-in-one insurer pleads guilty to three felonies

Kevin Kolenda, a Connecticut businessman who insurers golf tournament hole-in-one prizes but has a history of not paying, pleaded guilty today in King County Superior Court to two counts of selling insurance without a license and one count of first-degree theft.

Kolenda started Golf Marketing in 1995 and sold hole-in-one insurance coverage to charity golf tournaments across the country including in Washington state. He repeatedly failed to pay winning golfers, leaving charities to come up with the prize money. To skirt prosecution, he also changed the name of his business several times.

Other states where Kolenda sold bogus insurance including: Montana, Ohio, Georgia, California, New York, Hawaii, Alabama, Massachusetts, Florida, Connecticut and North Carolina.

Kolenda paid $10,000 in restitution today. He will pay another $5,000 in four months, when he returns to Seattle for sentencing.

What to do if your Medicare Advantage plan is going away

Medicare open enrollment starts Oct. 15. Some people may have already received a notice saying their Medicare Advantage plan is going away. If you or someone you know has received a notice, here's some steps to take:

  • Check with your medical providers and find out what Medicare Advantage plans they accept in 2014.
  • Read about your rights
  • Avoid a gap in coverage by selecting a new plan before Dec. 31
  • If you can't decide between a Medicare Advantage plan or returning to Original Medicare, see page 59 of the Medicare and You 2014 booklet for help

Need more help? Contact our free Statewide Health Insurance Benefits Advisors (SHIBA), They can  help your evaluate and compare plans. 

WAhealthplanfinder will be down tonight for system improvements

Washington's Exchange - the Wahealthplanfinder.org - is up and running, but some people are still experiencing slow loading times and difficulty submitting their applications. The Exchange is taking the website down tonight starting at 10 p.m. until 6 a.m. tomorrow morning to work on system improvements. Want an update on their progress? Check www.wahbexchange.org often.

I hear new health plans must meet 'actuarial value' standards - what's that mean?

All individual and small employer health plans sold inside and outside the new Health Benefit Exchange - Wahealthplanfinder.org - must have an actuarial value of at least 60 percent.

This means the plan must pay for least 60 percent of your medical costs for essential health benefits. Sixty percent is the standard for the new 'bronze level' plans. You also can choose from a silver level or gold metal level plan. Silver plans pay for 70 percent of your costs and gold pay for 80 percent.

Here's answers to additional questions about how the new 'actuarial value' works:

If my plan has an actuarial value of 70 percent  does that mean I will not have to pay more than 30 percent of my entire insurance costs?
No, the actuarial value is only based on the level of coverage the plan provides for essential health benefits.  If your plan has an actuarial value of 60 percent, for example, that means that the plan will pay 60 percent of your covered expenses for essential health benefits and you pay 40 percent of the covered expenses for essential health benefits. 
Although the actuarial value of your covered expenses for essential health benefits will be covered, you may have other costs such as deductibles, copays and coinsurance, as well as costs for services that are excluded or are not covered benefits.

Make sure you read your policy to see what services are excluded services.  Benefits that are not covered would be subject to the terms of your insurance policy, so it is important to read your policy before getting the service or treatment. 
What are essential health benefits? As of Jan. 1, 2014, all individual and small employer health plans must cover these 10 benefits:

  1. ambulatory patient services
  2. emergency services
  3. hospitalization
  4. maternity and newborn car
  5. mental health and substance use disorder services including behavioral health treatment
  6. prescription drugs
  7. rehabilitative and habilitative services and devices
  8. laboratory services
  9. preventive and wellness services, chronic disease management
  10. pediatric services ‐ including oral and vision care


Washington's Healthplanfinder now up and running

After a few hours of technical difficulties earlier today, Wahealthplanfinder.org is now up and running. There may be a few more glitches as additional issues are fixed, so if you're filling out an application, be sure to save your information. Also, the website will be down temporarily tonight at 8 p.m.

Eight health insurers have been approved to sell 46 different plans inside the Exchange. Remember, the Exchange is the only place you can go to receive federal tax subsidies to help lower your monthly premium - and there's only one official Exchange for our state - www.wahealthplanfinder.org.

If you earn more than the cut-off for a subsidy (about $46,000 for an individual and $94,200 for a family of four), you also can shop for insurance outside the Exchange. To see all of the plans available in your county - both inside and outside the new Exchange - check out this map.