I am trying to keep track of my iterations so I can compare the outcomes for model selection.
My code currently looks like this:
library(depmixS4)
n <- 2
for (i in 1:11) {
model <- mix(list(DCRF$Specify_SaO2 ~ 1, DCRF$Haematocrit_1 ~ 1, DCRF$Glasgow_Coma_Score ~ 1),
family = list(gaussian("identity"), # For every corresponding
gaussian("identity"), # indicator a family of distribution
multinomial("identity")), # should be indicated in the list.
data = DCRF,
nstates = n, # This is the number of classes
initdata = DCRF
)
fit.mod <- fit(model)
print(fit.mod)
n <- n + 1
}
Ideally, I would like variable fit.mod
to keep track of the corresponding value of n
, by writing to a new variable fit.modn
So I want to end up with the new variables fit.mod2
, fit.mod3
, fit.mod4
, and so on.