What could cause the incorrect number of linear predictors in the multinom family of a multinomial GAM?

huangapple go评论59阅读模式
英文:

What could cause the incorrect number of linear predictors in the multinom family of a multinomial GAM?

问题

抱歉,我只能为您提供代码的翻译部分:

这个错误返回:"* family的线性预测变量数量不正确 *";

我尝试过将响应变量更改为数值,并简化模型。我还尝试过在multinom() family参数中更改K,但没有帮助。

这里还有一些关于数据结构的信息:
数据结构

以及一些会话信息:
会话信息

有人对这个错误可能的原因有什么建议吗?

英文:

Consider the following model modeling nine genotypes (integer numbers) by their growth pattern (The ratio of plant height growth over plant diameter growth) over time (in day of the year).

m2 <- gam(list(Genotype_nr ~ s(Ratio, Doy)  +
            s(Individual, bs = "re") +
            s(Doy, Individual, bs = "re"),
            ~s(Ratio, Doy)  +
            s(Individual, bs = "re") +
            s(Doy, Individual, bs = "re")),
            family = multinom(K = 8),
            method = "REML",
          data = data2)

This returns the error "Error in gam(list(Genotype_nr ~ s(Ratio, Doy) + s(Individual, bs = "re") + : incorrect number of linear predictors for family"

I´ve tried changing the response variable to numeric and I´ve tried simplifying the model. Ive also tried altering K in the multinom() family argument but nothing helped.

Here is also some info on the structure of the data:
Data structure

and some session info:
Session info

Does anybody has a suggestion on what might be the cause of this error?

Thanks in advance!

答案1

得分: 0

你告诉模型有 9 个类别 (K = 8),但你只提供了 2 个线性预测器,而且它们都相同。你需要提供 8 个线性预测器。如果你想它们都包括相同的项,我们可以使用 ?formula.gam 中描述的快捷方式:

m2 <- gam(list(Genotype_nr ~ s(Ratio, Doy)  +
            s(Individual, bs = "re") +
            s(Doy, Individual, bs = "re"),
            ~ -1,
            ~ -1,
            ~ -1,
            ~ -1,
            ~ -1,
            ~ -1,
            ~ -1),
            family = multinom(K = 8),
            method = "REML",
          data = data2)

如果你想要不同的模型,你需要分别指定线性预测器。

英文:

You told the model that there were 9 classes (K = 8), but you only provided 2 linear predictors, both of which are the same. You need to provide 8 linear predictors. If you want them all to include the same terms we can use the short cut described in ?formula.gam:

m2 &lt;- gam(list(Genotype_nr ~ s(Ratio, Doy)  +
            s(Individual, bs = &quot;re&quot;) +
            s(Doy, Individual, bs = &quot;re&quot;),
            ~ -1,
            ~ -1,
            ~ -1,
            ~ -1,
            ~ -1,
            ~ -1,
            ~ -1),
            family = multinom(K = 8),
            method = &quot;REML&quot;,
          data = data2)

If you want different models, you need to specify the linear predictors separately.

huangapple
  • 本文由 发表于 2023年3月21日 02:37:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75794092-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定