Can anyone suggest a package or code for modeling a hysteresis process in R?
I'm currently modeling a certain dataset with a GAM using mgcv, something like gam(y~ s(x, by=z) + z, family = Gamma(link=log),data=data) and getting fits with about 9 estimated degrees of freedom in the smooth for each value of z. FWIW, z is a treatment applied to a system which should have made an improvement, and I'm trying to estimate the magnitude of that improvement (the aggregated change in y) assuming the x values did not vary. Looking at plots of y vs. x with lines connecting points in time order makes it clear that a significant hysteresis process is at work, and I conjecture I can reduce estimation uncertainty by modeling that hysteresis explicitly. I'm looking for a package that - can model hysteresis and return estimates of the fit in both the low and high states as well as statistics on the upper and lower hysteresis thresholds - has flexibility in the form of the model in the high and low states - While the current model uses GAMs because of the nature of the nonlinearity (I tried a number of other models before settling on this as a reasonable compromise), it may be that modeling the hysteresis directly would simplify the model a bit. Still, I'd like the flexibility to use GAMs if called for. - produces output that facilitates my using simulation to produce estimates of uncertainty in my inferences when I have new data for x, for example. I've searched R-bloggers, R-help, Google, and browsed a number of package manuals and vignettes. I've also looked at the cusp package; that and depmixS4 seem the most attractive so far, but I think it would take a bit of effort to make those work. My hysteresis problem is not quite a hidden Markov model, although the notion of putting covariates on transition parameters in depmixS4::depmix() seems promising. I've also thought of coding the model in JAGS. Before I go to that work, I thought I'd ask here to see if someone knows a good, existing solution. Thanks, Bill [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.