Wednesday, April 29, 2009

Nonlnear Models - GLS


### Indometh

ols<-nls(conc~SSbiexp(time,b1,b2,b3,b4),
data=Indometh[Indometh$Subject==1,])
beta<-coef(ols)

for(i in 1:10){
oldbeta<-beta
out<-nls(conc~SSbiexp(time,b1,b2,b3,b4),
data=Indometh[Indometh$Subject==1,],
weights=1/SSbiexp(time,beta[1],beta[2],beta[3],beta[4])^2)
beta<-coef(out)
}

BETA<-matrix(rep(0,6*4),6)
for(i in 1:6){
BETA[i,]<-coef(nls(conc~SSbiexp(time,b1,b2,b3,b4),
data=Indometh[Indometh$Subject==i,]))
}
colnames(BETA)<-c('b1','b2','b3','b4')


### Theoph
coplot(conc~Time | Subject, data=Theoph)
nls(conc~SSfol(Dose,Time,lKe,lKa,lCl),data=Theoph)
ols<-nls(conc~SSfol(Dose,Time,lKe,lKa,lCl),
data=Theoph[Theoph$Subject==1,])
beta<-coef(ols)

BETA<-matrix(rep(0,12*3),12)
for(i in 1:max(as.numeric(Theoph$Subject)))
BETA[i,]<-coef(nls(conc~SSfol(Dose,Time,b1,b2,b3),
data=Theoph[Theoph$Subject==i,]))


No comments: