简体   繁体   English

nls sslogis:使用虚拟变量作为交互项来比较两个S型模型

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

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 有两个级别的变量( V ): V1V2

  • Model 1: Fitting Y to X with a sigmoid function when V=V1 --> asymptote1 模型1:当V = V1->渐近线1时,通过S型函数将Y拟合到X
  • Model 2: Fitting Y to X with a sigmoid function when V=V2 --> asymptote2 模型2:当V = V2->渐近线2时,使用S型函数将Y拟合到X

Where asymptote1 and asymptote2 are not equal. 其中asymptote1asymptote2不相等。

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? 有什么方法可以将V用作相互作用项并获得相互作用系数? I introduces V-Dummy in the model and it generates the following error: 我在模型中引入了V-Dummy,它会产生以下错误:

Error in (attr(object, "initial"))(mCall = mCall, data = data, LHS = LHS) : too few distinct input values to fit a logistic model (attr(object,“ initial”))(mCall = mCall,data = data,LHS = LHS)中的错误:单独的输入值太少而无法满足逻辑模型

If not, what do you suggest as an alternative approach? 如果不是,您对替代方法有何建议?

Use nlme::gnls : 使用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. 默认情况下,这将为Asym返回两个参数:一个为基线水平(默认为V1 ),另一个为V1和V2之间的渐近差异。 summary() should include all of the usual inferential information (std error, p-value, etc.) summary()应该包括所有通常的推断信息(std错误,p值等)

From ?nlme::gnls : ?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. 参数:形式为'p1 + ... + pn〜x1 + ... + xm'的可选双向线性公式,或形式为'p1〜x1 + ... + xm'的双向公式列表,其中每个参数可能有不同的模型。 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). 'p1,...,pn'表示'模型'右侧包含的参数,'x1 + ... + xm'为参数定义线性模型(当公式的左侧包含多个参数时,都假定它们遵循右手边表达式描述的相同线性模型。 A '1' on the right hand side of the formula(s) indicates a single fixed effects for the corresponding parameter(s). 公式右侧的“ 1”表示相应参数的单个固定效应。 By default, the parameters are obtained from the names of 'start'. 默认情况下,参数是从“开始”的名称获得的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM