[R] help on lme extraction

2010-10-25 Thread Jin, Jp
Dear R list,

I need some help in extracting comparisons in the result of lme. I have a data 
set similar to the example data, Orthodont, using patient subject as a random 
effect and did something below:

library(nlme)
library(gregmisc)
data(Orthodont)
Orthodont$AgeGroup - gtools::quantcut(Orthodont$age)
fm2 - lme(distance ~ AgeGroup + Sex + AgeGroup*Sex, data = Orthodont, random = 
~1|Subject)
fit.contrast(fm2, Sex, c(-1,1), conf=0.95)
fit.contrast(fm2, AgeGroup, rbind(1 vs 2=c(-1,1,0,0), 2 vs 
3=c(0,-1,1,0)), conf=0.95)

But how can I compare different age groups among Male, Female or between Male 
and Female as illustrated below:
## among Male
 Male Female
[1,]   -1  0
[2,]1  0
[3,]0  0
[4,]0  0

## among Female
 Male Female
[1,]0  0
[2,]0 -1
[3,]0  0
[4,]0  1

## between Male and Female
 Male Female
[1,]   -1  0
[2,]0  0
[3,]0  0
[4,]0  1

I'll greatly appreciate it if you may help!

JP Jin Ph.D.
Bioinformatics scientist
Center for Bioinformatics
UNC at Chapel Hill
Chapel Hill, NC
US

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to use glm for a time course data set

2010-08-27 Thread Jin, Jp
Dear list,

I used glm to analyze the effect of treatment, measurement-methods etc. on 
lesion size in a time course experiments. Could anyone points me out how to 
extract detailed comparisons of interest?  For example:

Measurement.T2.M6 vs. Measurement.T2.Baseline, Or even
Measurement.T2.M6.Treatment vs. Measurement.T2.M6.placebo (I did not include 
Treatment as a factor in the query below yet).

 Thanks for your help (data was attached)!

Jp Jin

 summary(glm(data$Lesion.Size~Time+Measurement+Time*Measurement, data=data))

Call:
glm(formula = data$Lesion.Size ~ Time + Measurement + Time *
Measurement, data = data)

Deviance Residuals:
Min   1Q   Median   3Q  Max
-5344.9  -2494.8  -1289.5981.7  29248.7

Coefficients:
  Estimate Std. Error t value Pr(|t|)
(Intercept) 1352.7 1180.6   1.146   0.2546
Timem12  708.4 1669.7   0.424   0.6723
Timem6   630.6 1669.7   0.378   0.7064
MeasurementT2   4079.8 1669.7   2.443   0.0163 *
Timem12:MeasurementT2  -2400.5 2361.3  -1.017   0.3117
Timem6:MeasurementT2   -1763.5 2361.3  -0.747   0.4569
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 25090570)

Null deviance: 2787055253  on 107  degrees of freedom
Residual deviance: 2559238182  on 102  degrees of freedom
AIC: 2154.4

Number of Fisher Scoring iterations: 2


ID  Treatment   TimeMeasurement Relapse Lesion.Size
N01 placebo baselineT1  yes 3214
N01 placebo baselineT2  yes 6695
N01 placebo m6  T1  yes 2682
N01 placebo m6  T2  yes 6784
N01 placebo m12 T1  yes 2666
N01 placebo m12 T2  yes 8433.5
N05 placebo baselineT1  yes 1232
N05 placebo baselineT2  yes 1913.25
N05 placebo m6  T1  yes 652
N05 placebo m6  T2  yes 1909
N05 placebo m12 T1  yes 995
N05 placebo m12 T2  yes 1294.5
N07 statin  baselineT1  no  1378
N07 statin  baselineT2  no  3786.75
N07 statin  m6  T1  no  701
N07 statin  m6  T2  no  1382.25
N07 statin  m12 T1  no  818
N07 statin  m12 T2  no  1098.5
N08 placebo baselineT1  no  3522
N08 placebo baselineT2  no  8714.25
N08 placebo m6  T1  no  4115
N08 placebo m6  T2  no  8944.75
N08 placebo m12 T1  no  3456
N08 placebo m12 T2  no  9093.25
N10 placebo baselineT1  no  87
N10 placebo baselineT2  no  302.25
N10 placebo m6  T1  no  101
N10 placebo m6  T2  no  228.25
N10 placebo m12 T1  no  64
N10 placebo m12 T2  no  221.25
N11 statin  baselineT1  no  406.8
N11 statin  baselineT2  no  6456.6
N11 statin  m6  T1  no  1528
N11 statin  m6  T2  no  7726
N11 statin  m12 T1  no  2898
N11 statin  m12 T2  no  6880.75
N12 statin  baselineT1  no  721.6
N12 statin  baselineT2  no  21421.8
N12 statin  m6  T1  no  11464
N12 statin  m6  T2  no  20275.3
N12 statin  m12 T1  no  8
N12 statin  m12 T2  no  10187.3
N14 statin  baselineT1  no  418
N14 statin  baselineT2  no  1331.75
N14 statin  m6  T1  no  476
N14 statin  m6  T2  no  581.25
N14 statin  m12 T1  no  536
N14 statin  m12 T2  no  372.2
N15 placebo baselineT1  no  8103.5
N15 placebo baselineT2  no  34681.1
N15 placebo m6  T1  no  8710
N15 placebo m6  T2  no  14595.5
N15 placebo m12 T1  no  7215
N15 placebo m12 T2  no  12651.3
N16 placebo baselineT1  yes 644
N16 placebo baselineT2  yes 1253.25
N16 placebo m6  T1  yes 767
N16 placebo m6  T2  yes 1366.25
N16 placebo m12 T1  yes 1961
N16 placebo m12 T2  yes 1433
N17 statin  baselineT1  no  56
N17 statin  baselineT2  no  87.5
N17 statin  m6  T1  no  0
N17 statin  m6  T2  no  64.5
N17 statin  m12 T1  no  0
N17 statin  m12 T2  no  84.5
N19 statin  baselineT1  no  0
N19 statin  baselineT2  no  856.1
N19 statin  m6  T1  no  183
N19 statin  m6  T2  no  4065
N19 statin  m12 T1  no  1092
N19 statin  m12 T2