全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
2449 0
2016-03-31
一套数据出的三套题目,一点头绪都没有,目前只做出了第一大题第一小题……部分原因是英语太差……求高手指导……至少给点,思路,谢谢。数据已经附件上传

第一大题我试着写了下, 可是后两个小题一直报错……
####################Chapter11 exercise4(1)###################
allvar <- read.csv("H:/software/RStudio/files/allvar.csv")
HIV<-na.omit(allvar);
HIV;
time<-HIV$visage-HIV$baseage
HIV<-cbind(HIV,time);
for (i in 1:4) {plot(time[HIV$newpid==i],HIV$CD4PCT[HIV$newpid==i],xlab="time",ylab="CD4 percentage",type ="b")
  }

####################Chapter11 exercise4(2)###################
child<-0
MAX<-max(HIV$newpid);
for (i in 1:MAX){child<-lm(HIV$CD4PCT[HIV$newpid==i]~HIV$time[HIV$newpid==i])
}
child1<-lm(HIV$CD4PCT[HIV$newpid==1]~HIV$time[HIV$newpid==1]);
child2<-lm(HIV$CD4PCT[HIV$newpid==2]~HIV$time[HIV$newpid==2]);
child1
####################Chapter11 exercise4(3)###################
#step1
treatment<-0
for (i in 1:MAX) {treatment<-lm(HIV$CD4PCT[HIV$newpid==i]~HIV$treatmnt[HIV$newpid==i]+HIV$visage[HIV$newpid==i]}

11.7
The folder cd4 has CD4 percentages for a set of young children with HIV who
were measured several times over a period of two years. The dataset also includes
the ages of the children at each measurement.
(a) Graph the outcome (the CD4 percentage, on the square root scale) for each
child as a function of time.
(b) Each child’s data has a time course that can be summarized by a linear fit.
Estimate these lines and plot them for all the children.
(c) Set up a model for the children’s slopes and intercepts as a function of
the treatment and age at baseline. Estimate this model using the two-step
procedure–first estimate the intercept and slope separately for each child, then
fit the between-child models using the point estimates from the first step.
12.2
(a) Write a model predicting CD4 percentage as a function of time with varying
intercepts across children. Fit using lmer() and interpret the coefficient for
time.
(b) Extend the model in (a) to include child-level predictors (that is, group-level
predictors) for treatment and age at baseline. Fit using lmer() and interpret
the coefficients on time, treatment, and age at baseline.
(c) Investigate the change in partial pooling from (a) to (b) both graphically and
numerically.
(d) Compare results in (b) to those obtained in part (c).
13.4
(a) Extend the model in Exercise 12.2 to allow for varying slopes for the time
predictor.
(b) Next fit a model that does not allow for varying slopes but does allow for
different coefficients for each time point (rather than fitting the linear trend).
(c) Compare the results of these models both numerically and graphically.


附件列表

allvar.rar

大小:17.47 KB

 马上下载

本附件包括:

  • allvar.csv

allvar.xlsx

大小:70.14 KB

 马上下载

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群