library(Matrix)
library(MASS)

times<-c(0.77, 1.69, 2.69, 3.67, 4.69, 5.71, 7.94, 9.67, 11.77, 17.77, 
         23.77, 32.77, 40.73, 47.75, 54.9, 62.81, 72.88, 98.77, 125.92, 
         160.19, 191.15, 223.78, 287.7, 340.01, 340.95, 342.01)

doone<-function(k1=exp(-7.249610), 
                k2=exp(-1.582460), 
                k3=exp(-3.476060), 
                logSigma=-1.382815, 
                x0=c(0,100)){
  A<-rbind(
       c(-k1, k2),
       c( k1, -(k2+k3))
     )
  sol<-function(t)100-sum(expm(A*t)%*%x0)
  pred<-sapply(times,sol)
  
  sigma<-exp(logSigma)
  
  obs<-pred+rnorm(length(times),sd=sigma)
  return(cbind(times,obs))
}

dat<-doone()

# Write data in the same filename and format as the real data 

filen<-'min.dat'
cat('# noObs\n',length(times),'\n#  time terb\n', file=filen)
write.table(dat,row.names=FALSE, col.names=FALSE, file=filen, append=TRUE)



