> library(foreign)
> ds <- read.dta("c:/progesterone.dta")
> attach(ds)
> bf1 <- (time+7)*I(time > -7)
> bf2 <- (time+6)*I(time > -6)
> bf3 <- (time+5)*I(time > -5)
> bf4 <- (time+4)*I(time > -4)
> bf5 <- (time+3)*I(time > -3)
> bf6 <- (time+2)*I(time > -2)
> bf7 <- (time+1)*I(time > -1)
> bf8 <- (time)*I(time > 0)
> bf9 <- (time-1)*I(time > 1)
> bf10 <- (time-2)*I(time > 2)
> bf11 <- (time-3)*I(time > 3)
> bf12 <- (time-4)*I(time > 4)
> bf13 <- (time-5)*I(time > 5)
> bf14 <- (time-6)*I(time > 6)
> bf15 <- (time-7)*I(time > 7)
> bf16 <- (time-8)*I(time > 8)
> bf17 <- (time-9)*I(time > 9)
> bf18 <- (time-10)*I(time > 10)
> bf19 <- (time-11)*I(time > 11)
> bf20 <- (time-12)*I(time > 12)
> bf21 <- (time-13)*I(time > 13)
> bf22 <- (time-14)*I(time > 14)
> library(nlme)
> Const <- factor(rep(1,length(logp)))
> group.time <- group*time
> group.bf15 <- group*bf15
> model1 <- lme(logp ~ time + group + group.time + group.bf15,
+ random=list(Const=pdIdent(~-1 + bf1 + bf2 + bf3 + bf4 + bf5 + bf6 +
+ bf7 + bf8 + bf9 + bf10 + bf11 + bf12 + bf13 + bf14 + bf15 + bf16 +
+ bf17 + bf18 + bf19 + bf20 + bf21 + bf22), id=pdSymm(~time)))
> summary(model1)
Linear mixed-effects model fit by REML
Data: NULL
AIC BIC logLik
2140.95 2191.205 -1060.475
Random effects:
Formula: ~-1 + bf1 + bf2 + bf3 + bf4 + bf5 + bf6 + bf7 + bf8 + bf9 + bf10 + bf11 + bf12 + bf13 + bf14 + bf15 + bf16 + bf17 + bf18 + bf19 + bf20 + bf21 + bf22 | Const
Structure: Multiple of an Identity
bf1 bf2 bf3 bf4 bf5 bf6 bf7
StdDev: 0.1272939 0.1272939 0.1272939 0.1272939 0.1272939 0.1272939 0.1272939
bf8 bf9 bf10 bf11 bf12 bf13 bf14
StdDev: 0.1272939 0.1272939 0.1272939 0.1272939 0.1272939 0.1272939 0.1272939
bf15 bf16 bf17 bf18 bf19 bf20 bf21
StdDev: 0.1272939 0.1272939 0.1272939 0.1272939 0.1272939 0.1272939 0.1272939
bf22
StdDev: 0.1272939
Formula: ~time | id %in% Const
Structure: General positive-definite
StdDev Corr
(Intercept) 0.81091585 (Intr)
time 0.03225549 0.147
Residual 0.53484109
Fixed effects: logp ~ time + group + group.time + group.bf15
Value Std.Error DF t-value p-value
(Intercept) -0.8102153 0.5712916 1076 -1.418217 0.1564
time 0.0165396 0.0752331 1076 0.219844 0.8260
group 0.1625838 0.2322846 49 0.699934 0.4873
group.time -0.0478925 0.0119262 1076 -4.015750 0.0001
group.bf15 0.2961574 0.0232450 1076 12.740708 0.0000
Correlation:
(Intr) time group grp.tm
time 0.959
group -0.175 -0.007
group.time -0.022 -0.073 0.110
group.bf15 0.011 0.038 -0.046 -0.486
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-6.77317265 -0.37444577 0.07254333 0.48357956 3.68971584
Number of Observations: 1130
Number of Groups:
Const id %in% Const
1 51
> ranef(model1)
Level: Const
bf1 bf2 bf3 bf4 bf5 bf6 bf7
1 -0.01880284 -0.04151895 0.01521542 0.02093361 0.1021352 0.01119090 0.07303801
bf8 bf9 bf10 bf11 bf12 bf13 bf14
1 0.1204596 0.1345332 0.08573711 -0.1222685 -0.05969282 -0.1860887 -0.1398948
bf15 bf16 bf17 bf18 bf19 bf20
1 -0.1364576 -0.07127024 0.08151349 0.04012045 -0.04218653 -0.01595662
bf21 bf22
1 -0.05958696 -0.09459028
Level: id %in% Const
(Intercept) time
1/1 1.04262229 0.048006494
1/2 0.06321711 0.003916253
1/3 0.48219285 -0.002078017
1/4 0.05331022 0.025188754
1/5 0.34474514 0.007210268
1/6 -0.17557479 -0.001125460
1/7 -0.77353295 -0.017250197
1/8 -1.54691464 0.018135511
1/9 0.34404269 -0.003397573
1/10 -0.55860370 -0.051829917
1/11 0.79181905 0.029411680
1/12 -0.09610744 -0.006113602
1/13 1.59058790 0.027623495
1/14 1.25692721 0.046282511
1/15 -0.84867147 -0.040279913
1/16 0.46178167 -0.025152790
1/17 1.26550850 -0.020596790
1/18 -0.06117535 0.027268596
1/19 -0.48981496 0.006809565
1/20 0.24806778 -0.016989249
1/21 -1.65938752 -0.008185783
1/22 -0.43821171 0.012305125
1/23 -1.40460997 -0.043006595
1/24 0.99325825 -0.011639574
1/25 0.25249263 -0.001653297
1/26 -0.86806694 -0.024984184
1/27 -0.33890307 0.018885498
1/28 -0.35724516 0.016192651
1/29 0.42624640 -0.012953461
1/30 -0.01193843 0.019885476
1/31 0.32626920 0.004971129
1/32 0.29519032 0.000521182
1/33 -0.07867869 0.015730300
1/34 -0.01411617 0.015839614
1/35 0.54476270 0.021489751
1/36 0.23492604 -0.025986604
1/37 -1.10681371 -0.016572451
1/38 1.11267333 0.011245841
1/39 0.38006614 -0.040846472
1/40 0.15737615 0.005152397
1/41 0.08268456 0.021390259
1/42 -1.42182499 0.063007234
1/43 -0.73072761 -0.014838509
1/44 -0.43922571 0.005618548
1/45 -0.97190645 0.004090956
1/46 2.06726552 -0.016951502
1/47 -0.06663505 0.012473016
1/48 -0.64821092 -0.106965961
1/49 0.46933945 0.003035491
1/50 0.01967990 0.026952375
1/51 -0.20015561 -0.009242071