##############################
## READ IN PSI 1
##############################
data(denS4)
##############################
## PREPROCESS PSI 1
##############################
denS4<-preProcess(data = denS4, scalx2 = c(3.78, 643.5))
##############################
## READ IN PSI 2
##############################
data(denS5)
##############################
## PREPROCESS PSI 2
##############################
denS5<-preProcess(data = denS5, scalx2 = c(3.78, 643.5))
##############################
## DEFINE INITIAL MODEL
##############################
model1<- initModel(mod_type = "kin",
kinpar= c(7.9, 1.08, 0.129, .0225, .00156) ,
irfpar=c( -.1018, 0.0434),
disptau=FALSE, dispmu=TRUE, parmu = list(c(.230)),
lambdac = 650,
seqmod=TRUE,
positivepar=c("kinpar"),
title="S4",
cohspec = list( type = "irf"))
# \donttest{
##############################
## FIT INITIAL MODEL
##############################
denRes1 <- fitModel(data=list(denS4, denS5), list(model1),
opt=kinopt(iter=5, divdrel = TRUE, linrange = .2,
makeps = "den1", selectedtraces = c(1,5,10), plotkinspec =TRUE,
output="pdf", xlab = "time (ps)", ylab = "wavelength"))
##############################
## REFINE INITIAL MODEL, RE-FIT
## adding some per-dataset parameters
##############################
denRes2 <- fitModel(data = list(denS4, denS5), modspec = list(model1),
modeldiffs = list(dscal = list(list(to=2,from=1,value=.457)),
free = list(
list(what = "irfpar", ind = 1, dataset = 2, start=-.1932),
list(what = "kinpar", ind = 5, dataset = 2, start=.0004),
list(what = "kinpar", ind = 4, dataset = 2, start= .0159)
)),
opt=kinopt(iter=5, divdrel = TRUE, linrange = .2,
xlab = "time (ps)", ylab = "wavelength", output="pdf",
makeps = "den2", selectedtraces = c(1,5,10)))
##############################
## REFINE MODEL FURTHER AS NEW MODEL OBJECT
##############################
model2 <- initModel(mod_type = "kin",
kinpar= c(7.9, 1.08, 0.129, .0225, .00156),
irfpar=c( -.1018, 0.0434),
parmu = list(c(.230)),
lambdac = 650,
positivepar=c("kinpar", "coh"),
cohspec = list( type = "seq", start = c(8000, 1800)))
##############################
## FIT NEW MODEL OBJECT
##############################
denRes3 <- fitModel(data = list(denS4, denS5), list(model2),
modeldiffs = list(dscal = list(list(to=2,from=1,value=.457)),
free = list(
list(what = "irfpar", ind = 1, dataset = 2, start=-.1932),
list(what = "kinpar", ind = 5, dataset = 2, start=.0004),
list(what = "kinpar", ind = 4, dataset = 2, start= .0159)
)),
opt=kinopt(iter=5, divdrel = TRUE, linrange = .2,
makeps = "den3", selectedtraces = c(1,5,10), plotkinspec =TRUE,
stderrclp = TRUE, kinspecerr=TRUE, output="pdf",
xlab = "time (ps)", ylab = "wavelength",
breakdown = list(plot=c(643.50, 658.62, 677.5))))
# } # end donttest
##############################
## CLEANUP GENERATED FILES
##############################
# This removes the files that were generated in this example
# (do not run this code if you wish to inspect the output)
file_list_cleanup = c('den1_paramEst.txt', 'den2_paramEst.txt', 'den3_paramEst.txt',
Sys.glob("*paramEst.txt"), Sys.glob("*.ps"), Sys.glob("Rplots*.pdf"))
# Iterate over the files and delete them if they exist
for (f in file_list_cleanup) {
if (file.exists(f)) {
unlink(f)
}
}
Run the code above in your browser using DataLab