I have the following code to fit a sigmoidal function to my data:
nlsLM(mepAMP ~ plateau / (1 + exp(slope*(S50 - pMSO))),
data = df,
start = list(plateau = 7, S50 = 100, slope = 0.15)
From my understanding, nlsLM
(much like base nls
available in r) has the option of selecting upper and lower bounds for the data. I'd specifically like to constrain the plateau
to ≤8 mV to provide a physiologically plausible approximation of that parameter. Is there a way to constrain just one parameter? I've seen some posts where they specify upper = c(1000, 1)
or something along those lines, but I'm not sure if that constrains all parameters and how I could specify plateau
.
I've tried upper = c(8)
, but that gives me the following error:
Error in nls.lm(par = start, fn = FCT, jac = jac, control = control, lower = lower, :
length(upper) must be equal to length(par)
I can't seem to find the proper syntax for setting the upper bound and would appreciate any guidance.
EDIT:
Thank you Allan for your help. I included upper = c(plateau = 8, S50 = Inf, slope = Inf)
when I have multiple subjects, however, this seems to change not only the model fits where the plateau did go over 8, but also those that were nowhere close to that. Is this normal? I would think that it wouldn't touch the model fitting for those whose plateau was already below the constraint.