Description Usage Arguments Value Author(s) See Also Examples
Performs data sampling, selection, baseline correction,
scaling, and data correction on an object of class dat
.
1 2 3 4 5 6 | preProcess(data, sample = 1, sample_time = 1, sample_lambda = 1,
sel_time = vector(), sel_lambda = vector(), baselinetime = vector(),
baselinelambda = vector(), scalx = NULL, scalx2 = NULL,
sel_lambda_ab = vector(), sel_time_ab = vector(), rm_x2=vector(),
rm_x = vector(), svdResid = list(), numV = 0, sel_special = list(),
doubleDiff = FALSE, doubleDiffFile = "doubleDiff.txt")
|
data |
Object of class |
sample |
integer describing sampling interval to take in both time and
|
sample_time |
integer describing sampling interval in time; e.g.,
|
sample_lambda |
integer describing sampling interval in |
sel_time |
vector of length 2 describing the first and last time
index of data to select; e.g., |
sel_lambda |
vector of length 2 describing the first and last |
baselinetime |
a vector of form |
baselinelambda |
a vector of form |
scalx |
numeric by which to linearly scale the |
scalx2 |
vector of length 2 by which to linearly scale the
|
sel_lambda_ab |
vector of length 2 describing the absolute values
(e.g., wavelengths, wavenumbers, etc.) between which data should be
selected. e.g., |
sel_time_ab |
vector of length 2 describing the absolute times
between which data should be
selected. e.g., |
rm_x2 |
vector of |
rm_x |
vector of |
svdResid |
list returned from the |
numV |
numeric specifying how many singular vectors to use in data correction. Maximum is five. |
sel_special |
list of lists specifying |
doubleDiff |
logical indicating whether the data should be converted to represent differences between times. |
doubleDiffFile |
character string indicating the file name of
time difference data to create in the case that |
object of class dat
.
Katharine M. Mullen, Ivo H. M. van Stokkum
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | ##############################
## READ DATA
##############################
data("target")
##############################
## PREPROCESS DATA
##############################
# select certain wavelengths for modeling
C1_1 <- preProcess(data = C1, baselinelambda = c(1,12,1,32) )
C1_1 <- preProcess(data = C1_1, sel_lambda = c(8, 27))
C1_1 <- preProcess(data = C1_1, rm_x = c(40, 41, 101, 116))
C1_1 <- preProcess(data = C1_1, sel_time_ab = c(-10, 100000))
C2_1 <- preProcess(data = C2, sel_lambda = c(2, 32))
C2_1 <- preProcess(data = C2_1, baselinelambda = c(1,12,1,32) )
C2_1 <- preProcess(data = C2_1, sel_time_ab = c(-10, 100000))
C3_1 <- preProcess(data = C3, sel_lambda = c(1, 25))
C3_1 <- preProcess(data = C3_1, baselinelambda = c(1,12,1,32) )
## Not run:
##############################
## SPECIFY K Matrix and J vector
##############################
## initialize 2 7x7 arrays to 0
delK <- array(0, dim=c(7,7,2))
## the matrix is indexed:
## delK[ ROW K MATRIX, COL K MATRIX, matrix number]
## in the first matrix, put the index of compartments
## that are non-zero
## the transfer rate of the compartment is governed by
## kinpar[index]
delK[1,1,1] <- 4
delK[5,1,1] <- 1
delK[2,2,1] <- 4
delK[5,2,1] <- 2
delK[3,3,1] <- 4
delK[5,3,1] <- 3
delK[4,4,1] <- 4
delK[6,5,1] <- 5
delK[7,6,1] <- 6
delK[7,7,1] <- 7
## print out the resulting array to make sure it's right
delK
jvector <- c(.48443195136500550341, .28740782363398824522,
.13749071230100625137, 0.9066953510E-01, 0, 0, 0)
datalist <- list(C1, C2, C3)
## for plotting selected traces, get a vector of all the wavenumbers
allx2 <- vector()
for(i in 1:length(datalist))
allx2 <- append(allx2,datalist[[i]]@x2)
allx2 <- sort(unique(allx2))
##############################
## SPECIFY INITIAL MODEL
## note that low is the larger wavenumber in the clpequ spec!
##############################
model1 <- initModel(mod_type = "kin",
kinpar=c( 0.13698630, 0.3448275849E-01, 0.1020408142E-01, 0.2941176528E-02,
0.17000, 0.015, 0.1074082902E-03),
fixed = list(prel = 1:6, clpequ=1:3, kinpar=1:7, irfpar=1, parmu=1),
irfpar=c(0.4211619198, 0.6299000233E-01),
prelspec = list(
list(what1="kinpar", ind1=1, what2 = "kinpar", ind2=4,
start=c(-1,0.1369863003)),
list(what1="kinpar", ind1=2, what2 = "kinpar", ind2=4,
start=c(-1,0.3448275849E-01)),
list(what1="kinpar", ind1=3, what2 = "kinpar", ind2=4,
start=c(-1,0.1020408142E-01))
),
parmu = list(c(-0.1411073953)),
lambdac = 1290,
kmat = delK,
jvec = jvector,
positivepar="kinpar",
weightpar=list( c(-20,1.4,1,2000,.2)),
clpequspec =list(
list(to=2, from=1, low=100, high=10000),
list(to=3, from=1, low=100, high=10000),
list(to=4, from=1, low=100, high=10000)),
clpequ = c(1,1,1),
cohspec = list( type = "irf"))
##############################
## GET RESID
## same format as call to fitModel, but does not plot
##############################
serResid <- getResid(list(C1_1, C2_1, C3_1), list(model1),
modeldiffs = list(thresh = 0.00005,
dscal = list(list(to=2,from=1,value=4),
list(to=3,from=1,value=0.8000000119)),
free = list(
list(what="irfpar", ind=1, start= c(0.1231127158), dataset=2),
list(what="parmu", ind=c(1,1), start= c(0.1219962388), dataset=2),
list(what="irfpar", ind=1, start= c(0.3724052608), dataset=3),
list(what="parmu", ind=c(1,1), start= c(0.8844097704E-01), dataset=3)),
change = list(
list(what="fixed", spec=list(clpequ=1:3, kinpar=1:7, irfpar=1:2,
parmu=1, drel = 1, prel=1:6), dataset=2:3))),
opt=kinopt(iter=0, title="Cosimo Spectra, Not Normalized, with Error",
stderrclp=TRUE, kinspecerr=TRUE, writespec = TRUE,
plotkinspec = TRUE,plotcohcolspec=FALSE,
selectedtraces = seq(1, length(allx2), by=2),
specinterpol = TRUE, specinterpolpoints=FALSE,
divdrel=TRUE, xlab="wavenumber",writeclperr = TRUE,
makeps = "err", linrange = 1, superimpose=1:3))
##############################
## MAKE CORRECTED DATASETS USING RESID INFO
##############################
C1_3 <- preProcess(data = C1_1, svdResid = serResid[[1]], numV = 2)
C2_3 <- preProcess(data = C2_1, svdResid = serResid[[2]], numV = 2)
C3_3 <- preProcess(data = C3_1, svdResid = serResid[[3]], numV = 2)
##############################
## FIT MODEL
##############################
serRes<-fitModel(list(C1_3, C2_3, C3_3), list(model1),
modeldiffs = list(thresh = 0.00005,
dscal = list(list(to=2,from=1,value=4),
list(to=3,from=1,value=0.8000000119)),
free = list(
list(what="irfpar", ind=1, start= c(0.1231127158), dataset=2),
list(what="parmu", ind=c(1,1), start= c(0.1219962388), dataset=2),
list(what="irfpar", ind=1, start= c(0.3724052608), dataset=3),
list(what="parmu", ind=c(1,1), start= c(0.8844097704E-01), dataset=3)),
change = list(
list(what="fixed", spec=list(clpequ=1:3, kinpar=1:7, irfpar=1:2,
parmu=1, drel = 1, prel=1:6), dataset=2:3))),
opt=kinopt(iter=0, title="Cosimo Spectra, Not Normalized, with Error",
stderrclp=TRUE, kinspecerr=TRUE, writespec = TRUE,
plotkinspec = TRUE,plotcohcolspec=FALSE, writerawcon = TRUE,
selectedtraces = seq(1, length(allx2), by=2),
specinterpol = TRUE, specinterpolpoints=FALSE,
divdrel=TRUE, xlab="wavenumber",writeclperr = TRUE,
makeps = "h20", linrange = 1, superimpose=1:3))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.