I have a group of 200 children who came to clinic at months 0, 1, 2, 3, 6, 9, and 12 this year. At each clinic visit the children were weighed.
# Set seed to create reproducible example data
set.seed(50)
# Create patient ID numbers, genders, and ages
control <- NULL
control$Age_0 = round(runif(200,1,10), digits = 1)
# Create monthly weights
control$Weight_0 = ((control$Age_0 + 4) * 2)
control$Weight_1 = (control$Weight_0 * 1.1)
control$Weight_2 = (control$Weight_0 * 1.2)
control$Weight_3 = (control$Weight_0 * 1.3)
control$Weight_6 = (control$Weight_0 * 1.4)
control$Weight_9 = (control$Weight_0 * 1.6)
control$Weight_12 = (control$Weight_0 * 1.8)
# Store as data frame
control <- as.data.frame(control)
I want to study how their weights vary with time. I thought the best way to do this would be to simply plot their mean weights at every visit versus time.
# Plot mean weights versus time
plot(c(0,1,2,3,6,9,12), c(mean(control$Weight_0), mean(control$Weight_1), mean(control$Weight_2), mean(control$Weight_3), mean(control$Weight_6), mean(control$Weight_9), mean(control$Weight_12)), xlab = "Month", ylab = "Weight (Kilograms)", main = "Weight versus time", ylim = c(0,50))
I would like to put some vertical error bars on this plot. My questions are:
- Should I plot standard deviation, standard error, or a 95% confidence interval?
- How do I add vertical error bars to the plot?
There is another group of children who got growth hormone injections during the year. I want to compare their growth over time to that of the children in the control group.
# Create patient ID numbers, genders, and ages
growth <- NULL
growth$Age_0 = round(runif(200,1,10), digits = 1)
# Create monthly weights
growth$Weight_0 = ((growth$Age_0 + 6) * 2)
growth$Weight_1 = (growth$Weight_0 * 1.3)
growth$Weight_2 = (growth$Weight_0 * 1.4)
growth$Weight_3 = (growth$Weight_0 * 1.6)
growth$Weight_6 = (growth$Weight_0 * 1.8)
growth$Weight_9 = (growth$Weight_0 * 1.9)
growth$Weight_12 = (growth$Weight_0 * 2.0)
# Store as data frame
growth <- as.data.frame(growth)
plot(c(0,1,2,3,6,9,12), c(mean(growth$Weight_0), mean(growth$Weight_1), mean(growth$Weight_2), mean(growth$Weight_3), mean(growth$Weight_6), mean(growth$Weight_9), mean(growth$Weight_12)), xlab = "Month", ylab = "Weight (Kilograms)", main = "Weight versus time", ylim = c(0,50))
- Does this change the kind of error bars I should create (i.e., should I use confidence intervals if I want to examine whether or not there is a difference between the groups)?
- How do I plot this on the same plot as the control group?
Am I thinking of this problem the right way? Any other suggestions?