**Wiekvoet**, and kindly contributed to R-bloggers)

Based on last week’s faster algorithm I wanted to finish with car weights. Unfortunately a fail again. By now it is a fail of myself, it needs a bit more dedication and grunt than I am willing and able to give for this blog. This week I added some extra functions around the existing functions so I could harvest final results pretty easily. But the results seemed a bit odd at places, I ran the same again, the second time around they were a bit different. Nothing that seems unsolvable with a bit more attention, manually checking if stable sampler has been obtained, maybe tune the number of normal distributions which make the combined distribution.

Having said the negative, the pictures can be interpreted. The car market has changed from a double peaked distribution to a three peak distribution. Sales in recent years are mostly in the lowest weight category. The weight of cars in this category is slowly increasing though.

#### Data

Data were obtained as described here. I made an additional plot of the weights. These are the raw data weighted by the width of the categories.

lweight4 <- weight2[weight2$RefYear == weight2$BuildYear+1,]

weight4$lower <- lweightcats[weight4$Onderwerpen_2]

weight4$upper <- uweightcats[weight4$Onderwerpen_2]

datashow <- expand.grid(year=2000:2012,

weight=seq(500,2000,by=20))

datashow$y <-0

for (ii in 1:nrow(weight4)) {

datashow$y[datashow$weight>=weight4$lower[ii]

& datashow$weight<=weight4$upper[ii]

& datashow$year==weight4$BuildYear[ii]] <-

weight4$Waarde[ii]*100/(weight4$upper[ii]-weight4$lower[ii])

}

library(lattice)

levelplot(y ~ weight+ year , data=datashow, col.regions=

colorRampPalette(c(‘white’,’yellow’,’green’,’blue’,’purple’,’red’))

)

#### Modelling.

The nice thing about this plot is that it clearly shows three peaks within each year and a slow increase of the locations of the years. 2009 looks a bit odd though. The lowest category existed maybe at 2003, but really took off in 2010. In 2009 it also seems the heaviest cars got less popular, but this seems to be reverting slightly in 2011.

#### model flaws

A number of panes have separate lines, indicating different results. It seems the results of 2000, 2002 and 2009 are different, hence needing a bit more attention

#### R-code

**leave a comment**for the author, please follow the link and comment on their blog:

**Wiekvoet**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...