Publications by nzcoops
Mixed Models – Part 1
Very brief. Have been exploring mixed models in R using nlme::lme. Am looking forward to understanding them more, they’re going to be used more and more in years to come I’ve no doubt of that. Here are some scripts, very rough, for diagnostics when running simple 2 levels, or models with 1 grouping variable. CLICK HERE – To download the fir...
1298 sym 16 img
Mixed models – Part 2: lme lmer
Getting more into mixed models, I’ve been playing around with both nlme::lme and lme4::lmer. http://tolstoy.newcastle.edu.au/R/e2/help/06/10/3345.html was quite a good post at explaining the differences, which from what I gather is largely performance based when using crossed or partially crossed models. In the models I am tinkering with at th...
897 sym 16 img
Child health metrics
In analysis of Child Health data, generally z-scores or percentile groupings are used as children do not growth is not linear. The CDC (Center for Disease Control and Prevention) have released tables of data for calculating these z-scores and percentiles, and here are some scripts for R to calculate these in your sample. CLICK HERE – To downloa...
1204 sym 16 img
Graphing – margins, titles, mtext, workspace
This is a great post, very true, not enough of R’s graphics are well displayed online to really see how to achieve what the often ambiguous ‘help’ information suggests. http://research.stowers-institute.org/efg/R/Graphics/Basics/mar-oma/index.htm I particularly find “mtext(“lol”, outer=T)” to be particularly useful (requires “oma=...
910 sym 16 img
Anova – Type I/II/III SS explained
Not my post, just bookmarking this. It’s from http://goanna.cs.rmit.edu.au/~fscholer/anova.php ANOVA (and R) The ANOVA Controversy ANOVA is a statistical process for analysing the amount of variance that is contributed to a sample by different factors. It was initially derived by R. A. Fisher in 1925, for the case of balanced data (equal number...
9095 sym 16 img
More on logging the outcome
This one does my head in. I do it fairly regularly, lots of people do, but I find everytime it comes to interpreting the results I have to slow it right down and go step by step. Answer: When you log the outcome, then on the original scale, for all else constant, Y will be exp(b1*d) higher. Or, Y, your outcome on the original scale, will change b...
2957 sym R (279 sym/2 pcs) 16 img
Generating unique random IDs
Recently I was asked to help create random IDs for someone. At first I thought, ‘Ah yup, 1:x (1,2,3, …,x), job done’. Then I thought that there had to be a R function/package to create better looking IDs, to which I didn’t find one, if there is, please let me know. In the mean time I wrote this, which puts a random letter at the start, fo...
1182 sym R (658 sym/1 pcs) 16 img
gridExtra – Multiple plots from ggplot2
Thanks to this great post http://www.imachordata.com/?p=730 we can now put multiple plots on a display with ggplot2. This provides somewhat similar functionality to ‘par(mfrow=c(x,y))’ which would allow multiple plots with the base plot function. gridExtra doesn’t have quite the same level of options as ‘par’, but the syntax is simple....
1180 sym 16 img
ICD codes – Analysing hospitilisations
A brief first post on what I hope will be a series of posts on analysing hospitilisation data, which is recorded using ICD codes (International Statistical Classification of Diseases and Related Health Problems) Initially here is an R file. This can be read in and will create a list, 218 long, forming groupings using sub chapters of the ICD codin...
1348 sym 16 img
ICD code – search looping
Following on from my earlier post on creating a table of ICD codes in R, here is how I am currently counting these codes and storing the codes in a dataframe: Firstly create a dataframe to store the results in: hosp_count <- as.data.frame(matrix(ncol=length(icd_codes))) names(hosp_count) <- names(icd_codes) Counting Occurences: Then start to l...
2231 sym R (691 sym/3 pcs) 16 img