Getting to the point – an alternative to the bezier arrow

An alternative bezier arrow to the regular grid-bezier. Apart from a cool gradient it has the advantages of: exact width, exact start/end points and axis alignment.
An alternative bezier arrow to the regular grid-bezier. Apart from a cool gradient it has the advantages of: exact width, exact start/end points and axis alignment.

About two weeks ago I got frustrated with the bezierGrob function in the grid package. The lwd parameter is interpreted differently depending on device, the arrow at the end does not follow the line but is perpendicular (probably following the spline control), and the line parameter makes it difficult to control exactly where the line starts/ends. Thus I decided to make my own fancy line with an arrow at the end – at the time I thought: How hard can it be? In retrospect, I wish I never thought of the thing… This article is about the painful process of creating of an alternative to the bezierGrob. Continue reading

Posted in R | Tagged , , | Leave a comment

Extracting comorbidities from a database in SPSS

Using large databases for extracting data can be cumbersome, fortunately it's more reliable than sifting for gold. The image is CC by Won-Tolla.
Using large databases for extracting data can be cumbersome, fortunately it’s more reliable than sifting for gold. The image is CC by Won-Tolla.

I put a lot of effort in to my first article to calculate the comorbidities of a patient according to the Charlson & Elixhauser scores. The available scripts were in SAS and Stata, as I started out using SPSS I decided to implement the code in the neat Python plugin that SPSS provides. In this post I’ll provide you with a detailed walk through of my code, and hopefully it will save you some time. Continue reading

Posted in Research | Tagged , | Leave a comment

Age before beauty

Sticking to the old, proven concepts have often turned out to be a good strategy in orthopaedics. Switching hip implants can be both cumbersome and hazardous. The image is CC by Trey Ratcliff.
Sticking to the old, proven concepts have often turned out to be a good strategy in orthopaedics. Switching hip implants can be both cumbersome and hazardous. The image is CC by Trey Ratcliff.

In my research I focus on patient factors and their impact on re-operation rates after total hip arthroplasties. While they do matter, the implant itself seems to be even more important. One of the most successful implant in the Swedish Hip Arthroplasty Registry is the Link Lubinus SP II implant, while some may argue that it’s an awesome design, I would argue that the tools that it comes with are awesome, thus limiting surgeon’s mistakes. This importance of skill is nicely illustrated in Peltola et al’s recent study, where they found an increased risk for revision during the first 3 years when introducing new implants, hazard ratio was 1.3 (95% CI 1.1 to 1.5) for the first 15 arthroplasties. This increased risk early on is commonly referred to as the learning curve, and may vary between implants.

Peltola et al used the Finnish arthroplasty register, looked for how many stems/cups had been implanted of that kind at the particular hospital, categorized into five groups (1-15, 16-30, 31-50, 51-100, and > 100), and then looked at early and late revision rates. The only group with statistical significance was the 1-15, there were some other groupings but after reading the table 5 a couple of times I’m not sure it actually added anything but confusion. Although the other groups were not significant, this is clearly clinically relevant in Finland as one in seven patients receive an implant during its introduction.

I’m glad to see that more advanced statistical approaches are gaining ground, and their methods section was extensive. Even though I’m left with a few thoughts:

  • Introducing new implants at large volume hospitals, assuming that these have more surgeons, the time until each surgeon becomes experienced should increase, i.e. an interaction between hospital volume and the number of implanted stems/cups of the new kind.
  • While categories often are used, it would be interesting to see a more dynamic interpretation of the number of surgeries – as a spline enthusiast I would suggest applying these. It is interesting that they didn’t do this, while they at the same time used a smoother for the revision risk, se below image.

    A smoothing plot showing the hazard in relation to the years after surgery, early on there is an increased risk that then drops to a minimum around 4-5 years, where after it again increases. As a technical note it is interesting that they forgot to add the y-axis label, “Smoothed hazard function” is not a valid y-axis label in my opinion.
  • Were some of these new implants early on abandoned? It is plausible that a clinic tries a certain implant, finds it clumsy or underperforming, and abandons it early on. This would introduce a negative bias for the small series.
  • Sometimes an implant can boomerang, i.e. come and go, unclear if this taken into account.
  • They adjusted for sex and age, and table 3 indicates little difference. Shouldn’t the adjustment rather be implant fixation type or some other implant confounder? It would also be interesting to see if there is a difference in introduction estimate depending on what kind of fixation is used. Uncemented stems are for instance more susceptible to fractures and surgeon’s experience is critical, while cementing may in the inexperienced hand both lead to malpositioning and a poor fixation due to correction while the cement hardens.
  • Table 5 indicates the most common implants and the implants learning curve differ, annoyingly they chose to number the implants putting unnecessary effort on the reader. This could be used for the above bullet but the wide confidence intervals suggest that this grouping is not optimal for the data set.
  • I’m also hesitant about the exclusion criteria, why did they include bone grafts – this is clearly a rare procedure that may demand very specific implants. They should also have excluded implants with small series, a lot of implants are tested in small research series – if these are excluded small series will naturally have a negative bias.

As a surgeon I’m overall pleased to see these results – my expertise matters! Patients sometimes ask me what implant we use, I always answer: one that has a proven track record and that I’m familiar with. While the study may seem complicated if you look at the method section, the conclusion is simple: don’t change implant on a whim – make sure it will truly be better than your old one or you’re putting patients at risk.

M. Peltola, A. Malmivaara, and M. Paavola, “Hip prosthesis introduction and early revision risk,” Acta Orthopaedica, vol. 84, no. 1, pp. 25–31, Feb. 2013.

Posted in Orthopaedic surgery | Tagged , , | Comments Off

Using the SVD to find the needle in the haystack

Sitting on a data set with too many variables? The SVD can be a valuable tool when you're trying to sift through a large group of continuos variables. The image is CC by Jonas in China.
Sitting with a data set with too many variables? The SVD can be a valuable tool when you’re trying to sift through a large group of continuos variables. The image is CC by Jonas in China.

It can feel like a daunting task when you have a > 20 variables to find the few variables that you actually “need”. In this article I describe how the singular value decomposition (SVD) can be applied to this problem. While the traditional approach to using SVD:s isn’t that applicable in my research, I recently attended Jeff Leek’s Coursera class on Data analysis that introduced me to a new way of using the SVD. In this post I expand somewhat on his ideas, provide a simulation, and hopefully I’ll provide you a new additional tool for exploring data. Continue reading

Posted in R | 3 Comments

Stroke and THR

Can the promise of the new life after a total hip arthroplasty becom shattered by a stroke? The image is CC by Andreas Levers.
Can the promise of the new life after a total hip arthroplasty becom shattered by a stroke? The image is CC by Andreas Levers.

A recent study from Denmark by Lalmohamed et al. looked at stroke risk after total hip replacements. It is interesting as this is a severe disease that can have a major impact on the life after a total hip arthroplasty. Even if it’s a rare event, the rates are similar to other serious negative outcomes such as early infections (less than 1%), and therefore just as valid endpoint to study. Continue reading

Posted in Orthopaedic surgery | Leave a comment

Exporting plain, lattice, or ggplot graphics

A blend between a basic scatterplot, lattice scatterplot and a ggplot
A blend between a basic scatterplot, lattice scatterplot and a ggplot

In a recent post I compared the Cairo packages with the base package for exporting graphs. Matt Neilson was kind enough to share in a comment that the Cairo library is now by default included in R, although you need to specify the type=”cairo” option to invoke it. In this post I examine how the ggplot and the lattice packages behave when exporting. Continue reading

Posted in R | Tagged , , | 4 Comments

Dr. when can I drive again?

When is it appropriate to return to driving? The image is CC by K嘛.
When is it appropriate to return to driving? The image is CC by K嘛.

As an orthopaedic surgeon I’m often confronted by patients asking me when they can return to driving. While this is a natural question, the answer is surprisingly difficult for us doctors. It is therefore nice to read MacLeod et al.’s and Fleury et al.’s excellent reviews on this subject, and yes: I’ve thankfully been in line with the evidence. Continue reading

Posted in Orthopaedic surgery | Leave a comment

Exporting nice plots in R

It's not always easy getting the right size. The image is CC by Kristina Gill.
It’s not always easy getting the right size. The image is CC by Kristina Gill.

A vital part of statistics is producing nice plots, an area where R is outstanding. The graphical ablility of R is often listed as a major reason for choosing the language. It is therefore funny that exporting these plots is such an issue in Windows. This post is all about how to export anti-aliased, high resolution plots from R in Windows. Continue reading

Posted in R | 4 Comments

Spinal vs general anesthesia

Drops from a needle. The image is CC by Evan Leeson
Drops from a needle. The image is CC by Evan Leeson

Many of us orthopaedic surgeons have been frustrated by waiting for the anesthesiologist to finish with the spinal anesthesia. It is therefore of great relief that Pugely et al write that this frustration is not in vain. Patients that receive spinal anasthesia seem to have fewer complications after a total knee arthroplasty than those with general anesthesia, at least based on a large registry study with 14 000 patients. The overall odds ratio was though not that impressive, 1.3. Continue reading

Posted in Orthopaedic surgery, Research | Leave a comment

Tables from R into Word

A good looking table matters!
A good looking table matters!

This tutorial is on how to create a neat table in Word by combining knitr and R Markdown. I’ll be using my own function, htmlTable, from the Gmisc package.

Background: Because most journals that I submit to want the documents in Word and not LaTeX, converting my output into Word is essential. I used to rely on converting LaTeX into Word but this was tricky, full of bugs and still needed tweaking at the end. With R Markdown and LibreOffice it’s actually rather smooth sailing, although I must admit that I’m disappointed at how bad Word handles html. Continue reading

Posted in R | 4 Comments