I'd like to do the following and need some help:
Calculate slope and intercept for "Height" over "Age" [lm(Height~Age)] separately for
(A) each individual
(B) gender
and create a table containing the results (slope and intercept). Can I use "apply" for this?
In a next step I would like to do a statistical test to determine if slope and intercept are significantly different between Gender. I know how to do the test in R but maybe there is a way to combine slope/intercept calculation and T-testing.
Example data:
example = data.frame(Age = c(1, 3, 6, 9, 12,
1, 3, 6, 9, 12,
1, 3, 6, 9, 12,
1, 3, 6, 9, 12),
Individual = c("Jack", "Jack", "Jack", "Jack", "Jack",
"Jill", "Jill", "Jill", "Jill", "Jill",
"Tony", "Tony", "Tony", "Tony", "Tony",
"Jen", "Jen", "Jen", "Jen","Jen"),
Gender = c("M", "M", "M", "M", "M",
"F", "F", "F", "F", "F",
"M", "M", "M", "M", "M",
"F", "F", "F", "F", "F"),
Height = c(38, 62, 92, 119, 165,
31, 59, 87, 118, 170,
45, 72, 93, 155, 171,
33, 61, 92, 115, 168))