Hi, I'm pretty new to OpenMx, having only used it off-and-on over the past few years. That said, I am pretty interested in using it more, especially given the multilevel modeling capabilities (e.g., as discussed in Pritkin et al., 2017). However, my question isn't about the multilevel modeling capabilities, my question is about fitting non-linear models.
I am looking at trying to fit an exponential decay/growth model. It would look something like this: y~b2+(b0-b2)*exp(b1*time). Where b1 is constrained to be negative (so that everything after b2 eventually drops out of the model as time goes to infinity). The problem I'm running into is that it isn't clear to me how to include a parameter in the exponential part of the model. I ran across this thread [6] on including non-linear constraints, but I can't seem to figure out how to adapt that code to my issue. A (not working) minimal example is below:
time=seq(0, 100, by=0.01) y<-1+(5-1)*exp(-.1*time)+rnorm(length(time),sd=.2) data_list<-data.frame( time=time, y=y ) plot(time,y) modelExp<-mxModel("exp", type="RAM", manifestVars=c(names(data_list)), latentVars = "b1", mxPath(from="b1", to="b1", free=F, value=0, arrows=2), mxPath(from="one", to="b1", value=-.1), mxAlgebra(exp(b1*data.time), name="expPart"), mxPath(from="one", to="y", label="b2"), mxPath(from="time", to="y", label="expPart"), mxPath(from="one", to="time"), mxData(data_list, type="raw") ) fit<-mxRun(modelExp)
Part of the problem is that I can't figure out how to reference the parameter b1 (which I am using a zero variance latent variable for) in the mxAlgebra. The other part of the problem is, based on the previous thread I mentioned, I don't see a way to estimate the (b0-b2) part. I don't think I actually need to estimate those as two separate parameters (I already estimate b2 as a kind of intercept, so I can just estimate b0-b2 as some single parameter b* and then do the algebra separately), but it looks like the model with try to make "expPart" equal to b0-b2.
It's entirely possible that I am either trying to do something entirely unreasonable, or something trivially easy in an overly complicated way, but regardless it escapes me how I would do this and any help would be greatly appreciated.