#Gamlss 练习2
#a)Load the CD4 data and print the variable names
data(CD4)
names(CD4)
#b)Fit the SEP2 model in the course notes, by first fitting a PE model and using its
#fitted values as starting values for fitting the SEP2 model
mPE<-gamlss(cd4~pb(age),sigma.fo=~pb(age),data=CD4,family=PE)
mSEP2<-gamlss(cd4~pb(age),sigma.fo=~pb(age),data=CD4,family=SEP2,start.from=mPE,n.cyc=100)
#c)For the SEP2 model,print the total effective degrees of freedom and plot the fitted parameters
#against age
mSEP2$mu.df
mSEP2$sigma.df
fittedPlot(mSEP2,x=CD4$age)#绘制参数对于因变量的图
#d)For the SEP2 model look at the residual and worm plot and Q statistics
wp(mSEP2,xvar=CD4$age,ylim.worm=1.5)#查看残差图
#e)For your chosen model look at the centile curves
centiles(mSEP2,CD4$age,cent=c(0.4,2.10,25,50,75,90,98,99.6))
GAMLSS拟合连续分布练习2-代码及注释
最新推荐文章于 2023-10-17 18:39:44 发布