nls sslogis: using a dummy variable as an interaction term to compare two sigmoid models

504 Views Asked by At

I use the following model in my code:

model <- nls(y ~ SSlogis(x, Asym, xmid, scal), 
   data = data.frame(x, y))

There is a variable (V) with two levels: V1 and V2

  • Model 1: Fitting Y to X with a sigmoid function when V=V1 --> asymptote1
  • Model 2: Fitting Y to X with a sigmoid function when V=V2 --> asymptote2

Where asymptote1 and asymptote2 are not equal.

How can we show that the asymptotes are significantly different?

Is there any way to use V as an interaction term and get the interaction coefficient? I introduces V-Dummy in the model and it generates the following error:

Error in (attr(object, "initial"))(mCall = mCall, data = data, LHS = LHS) : too few distinct input values to fit a logistic model

If not, what do you suggest as an alternative approach?

1

There are 1 best solutions below

0
On

Use nlme::gnls:

model <- gnls(y ~ SSlogis(x, Asym, xmid, scal), 
              data = data.frame(x, y),
              params = list(Asym ~ V))

By default, this will return two parameters for Asym: one for the baseline level (V1 by default) and one for the difference in asymptotes between V1 and V2. summary() should include all of the usual inferential information (std error, p-value, etc.)

From ?nlme::gnls:

params: an optional two-sided linear formula of the form ‘p1+...+pn~x1+...+xm’, or list of two-sided formulas of the form ‘p1~x1+...+xm’, with possibly different models for each parameter. The ‘p1,...,pn’ represent parameters included on the right hand side of ‘model’ and ‘x1+...+xm’ define a linear model for the parameters (when the left hand side of the formula contains several parameters, they are all assumed to follow the same linear model described by the right hand side expression). A ‘1’ on the right hand side of the formula(s) indicates a single fixed effects for the corresponding parameter(s). By default, the parameters are obtained from the names of ‘start’.