Presentation is loading. Please wait.

Presentation is loading. Please wait.

 iq {spida}  创伤性脑损伤后智商恢复数据  ( IQ after traumatic brain injuries )

Similar presentations


Presentation on theme: " iq {spida}  创伤性脑损伤后智商恢复数据  ( IQ after traumatic brain injuries )"— Presentation transcript:

1

2  iq {spida}  创伤性脑损伤后智商恢复数据  ( IQ after traumatic brain injuries )

3  DAYSPC: 昏迷苏醒后天数  DCOMA :昏迷天数  SEX :性别  AgeIn : 受伤时的年龄  ID :身份  PIQ :行为 IQ  VIQ :语言 IQ

4  iq 为原始数据集  iqsim 为针对一个病人在 10 个观测恢复天数 上的模拟数据集

5

6

7  tab(~ID,iq)  tab(~DAYSPC,iq)  tab(tab(~ID,iq))  tab(tab(~DAYSPC,iq))  xyplot( PIQ ~ DAYSPC, iq, groups = ID)  tab(~ID+SEX,iq)  iq.id=up(iq,~ID,all=T)  tab(~ID+SEX,iq.id)

8

9

10  多项式 (polynomials)  样条( splines )  指数增长(衰减) exponential growth(decay)  周期( periodic )

11  线性方程( linear )  二次方程( quadratic )  三次方程 (cubic)  四次方程 (quartic)

12

13  plot(iq~days,iqsim,xlim=c(0,800),ylim=c(85,12 0))  fit.lin<-lm(iq~days,iqsim)  pred<-expand.grid(days=seq(-20,800,1))  pred$iq.lin<-predict(fit.lin,pred)  lines(iq.lin~days, pred,lwd=2)

14  fit.quad<-lm(iq~days+I(days^2),iqsim)  pred$iq.quad<-predict(fit.quad,pred)  lines(iq.quad~days,pred,col="red",lwd=2)

15  fit.cub<-lm(iq~days+I(days^2)+I(days^3),iqsim)  summary(fit.cub)  pred$iq.cub<-predict(fit.cub,pred)  lines(iq.cub~days,pred,col="blue",lwd=2)

16  p8<-function(x) poly(x,8,raw=T)  #raw if true, use raw and not orthogonal polynomials.  fit.8<-lm(iq~p8(days),iqsim)  summary(fit.8)  p9<-function(x) poly(x,9,raw=T)  fit.9<-lm(iq~p9(days),iqsim)  summary(fit.9)  pred$iq.8<-predict(fit.8,pred)  lines(iq.8~days,pred,col="green",lwd=2)

17

18

19

20  IRRR (瞬间相对恢复率)

21

22

23  公式 iq~b0+b1*exp(-alpha*days)  b0 长期水平, b1 在时间 0 点的相对差额 alpha 恢复率

24  fit.nl<-nls(iq~b0+b1*exp(- alpha*days),iqsim,start=list(b0=100,b1=- 20,alpha=0.005))  summary(fit.nl)  pred$iq.nl<-predict(fit.nl,pred)  lines(iq.nl~days,pred,col="purple",lwd=2)  abline(h=coef(fit.nl)[1],col="gray",lwd=2)

25  ttime<-function(x)exp( *x)  fit.lin<-lm(iq~ttime(days),iqsim)  summary(fit.lin)

26

27 fit.nlme<-nlme(PIQ~b0+b1*exp(- a*DAYSPC)+b.sex*(SEX=="Female"), data=iq, fixed=list(b0~1+sqrt(DCOMA), b1~1+sqrt(DCOMA),a~1,b.sex~1), random=list(ID=list(b0~1,b1~1)), control=list(maxIter=200,returnObject=T), start=list(fixed=c(100,-10,-20,1,0.05,0)), verbose=T )

28 fit.nlme<-nlme(PIQ~b0+b1*exp(-a*DAYSPC), data=iq, fixed=list(b0~1+sqrt(DCOMA), b1~1+sqrt(DCOMA),a~1), random=list(ID=list(b0~1,b1~1)), control=list(maxIter=200,returnObject=T), start=list(fixed=c(100,-10,-20,1,0.05)), verbose=T )

29  Their algorithm proceeds in two alternating steps, a penalized nonlinear least squares (PNLS) step and a linear mixed- effects (LME) step

30

31  D=G 随机效应的协方差矩阵

32

33

34  最大循环 100 次,不收敛也返回值  verbose=T 显示 PNLS 和 LME 步骤

35

36  plot(fit.nlme,resid(.,type="p")~fitted(.))  plot(fit.nlme,sqrt(abs(resid(.,type="p")))~fitted (.))  plot(ranef(fit.nlme))  pairs(ranef(fit.nlme))

37 fit.nlme.viq<-nlme(VIQ~b0+b1*exp(-a*DAYSPC), data=iq, fixed=list(b0~1+sqrt(DCOMA), b1~1+sqrt(DCOMA),a~1), random=list(ID=list(b0~1,b1~1)), control=list(maxIter=100,returnObject=T), start=list(fixed=c(100,-1,-10,-5,0.01)), verbose=T )

38  fit.nlme.viq<-nlme(VIQ~b0+b1*exp(-a*(DAYSPC- 30)),  data=iq,  fixed=list(b0~1+sqrt(DCOMA),  b1~1+sqrt(DCOMA),a~1),  random=list(ID=list(b0~1,b1~1)),  control=list(maxIter=100,returnObject=T),  start=list(fixed=c(100,-1,-10,-5,0.01)),  verbose=T  )

39 fit.nlme.viq<-nlme(VIQ~b0+b1*exp(-a*(DAYSPC-30)), data=iq, fixed=list(b0~1+sqrt(DCOMA), b1~1+sqrt(DCOMA),a~1), random=list(ID=list(b0~1,b1~1)), control=list(maxIter=100,returnObject=T), start=list(fixed=c(100,0,-10,-2,0.02)), verbose=T, subset=DCOMA<100 )

40  给定不同的初始值结果并不相同。  start=list(fixed=c(100,-0.3,-10,0,0.3))  b1 的随机效应可去掉

41 fit.nlme.piq<-nlme(PIQ~b0+b1*exp(-a*(DAYSPC-30)), data=iq, fixed=list(b0~1+sqrt(DCOMA), b1~1+sqrt(DCOMA),a~1), random=list(ID=list(b0~1,b1~1)), control=list(maxIter=100,returnObject=T), start=list(fixed=c(100,-0.3,-10,0,0.1)), verbose=T, subset=DCOMA<100 ) summary(fit.nlme.piq)

42

43 windows( height = 7, width = 8.5) pred <- expand.grid( DCOMA=c(0,1,7,16,25,100), DAYSPC = seq(30,365*2,5)) pred$piq <- predict( fit.nlme.piq, pred,level=0) pred$viq <- predict( fit.nlme.viq, pred,level=0 ) zz <- factor( paste( 'DCOMA =', pred$DCOMA)) pred$DCOMA.lab <- reorder( zz, pred$DCOMA) td( col = c('green','red'), lwd = 2) xyplot( viq + piq ~ DAYSPC |DCOMA.lab, pred, type = 'l', ylim = c(60,102), lwd = 2, auto.key = list(columns = 2, points = F, lines = T))

44

45 pred2 <- expand.grid( DCOMA = 0:100, DAYSPC = c(30,60,90.180,360,720)) pred2$piq <- predict( fit.nlme.piq, pred2, level = 0 ) pred2$viq <- predict( fit.nlme.viq, pred2, level = 0 ) zz <- factor( paste( 'DAYSPC =', pred2$DAYSPC)) pred2$dayspc.lab <- reorder( zz, pred2$DAYSPC) xyplot( viq + piq ~ DCOMA | dayspc.lab, pred2, type = 'l', ylim = c(60,102), lwd = 2, auto.key = list(columns = 2, points = F, lines = T))

46

47 predviq <- expand.grid( DCOMA = seq(0,100,10), DAYSPC = seq(30,720,30)) predpiq <- predviq predviq $ iq <- predict( fit.nlme.viq, predviq, level = 0) predpiq $ iq <- predict( fit.nlme.piq, predpiq, level = 0) predpiq$type <- factor( "PIQ" ) predviq$type <- factor( "VIQ" ) wireframe( iq ~ DAYSPC + DCOMA | type, Rbind( predpiq, predviq))

48

49 wireframe( iq ~ DCOMA+DAYSPC | type, Rbind( predpiq, predviq),scales = list( arrows = F), col = 'blue') wireframe( iq ~ DCOMA+DAYSPC | type, Rbind(predpiq, predviq), scales = list( arrows = F), col = 'blue', xlab = 'Coma', ylab = 'Days post coma', screen = list( z = -65, x = -75 ))

50 wireframe( iq ~ DCOMA+DAYSPC, Rbind(predpiq, predviq), groups = type, scales = list( arrows = F), col = 'blue', xlab = 'Coma', ylab = 'Days post coma', screen = list( z = -65, x = -75 ), auto.key = list(columns=2, lines = T, points = F), alpha =.5)

51

52


Download ppt " iq {spida}  创伤性脑损伤后智商恢复数据  ( IQ after traumatic brain injuries )"

Similar presentations


Ads by Google