【问题标题】:GAMLSS Error: Response Variable out of rangeGAMLSS 错误:响应变量超出范围
【发布时间】:2018-08-21 23:28:35
【问题描述】:

我无法理解为什么会收到此错误。我的两个变量都是数字且长度相同,当它们不是时,我用 NA 调整数据;但是我仍然收到我的响应变量超出范围的错误

    year <- c(1,2,3,4,5,6,7,8,9,10)
    y <- c(19.36, 0, 0, 0.06, 0,0, 1.58, 2.37, 0,0)
    x1 <- c(99.735835998,32.73874517,10.8545887,47.96341768,6.29940882,22.55498627,16.64656661,4.234896268,0.571722269,53.45872813)

    months = c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

    Drivers = c("P","T")
    ModelName = paste0(Drivers[1],"_",Drivers[2])
    ModelNumb = 2

for (s in 1:length(months))
{

  station_summary = data.frame(matrix(NA,length(stations),3))
  colnames(station_summary)=c("Station", "ModelName", "ModSelection")
  month = months[s]

  for (se in 1:length(stations))
  {

    station = stations[se]
    table = read.csv(paste0("D:/BF_Factors/Regroup Drivers/All_Drivers_BF_P_T/",station,"/Table_",station,"_",month,".csv"),sep=",",header = T)
    table = subset(table, select=c("Year","BF",Drivers))
    table = table[1:50,]

    # Clean the data according to the model used. Some years have been excluded because no data where available

    table[is.na(table[,2]),3] = NA
    table[is.na(table[,2]),4] = NA
    table[is.na(table[,3]),2] = NA
    table[is.na(table[,3]),4] = NA
    table[is.na(table[,4]),2] = NA
    table[is.na(table[,4]),3] = NA

    if (length(which(table[,2]>0))>=5) # If at least 5 values are higher than 0
    {

      x1 = table$P #first Driver
      x2 = table$T

     mod.GA1 <- gamlss(y~x1,sigma.fo=~1,family=GA) 
     mod.GA2 <- gamlss(y~x1+x2,sigma.fo=~1,family=GA)

gamlss 中的错误(公式 = table$BF ~ x1 + x2,family = GA): 响应变量超出范围 另外:有50个或更多的警告(使用warnings()查看前50个)

【问题讨论】:

    标签: gam


    【解决方案1】:

    问题在于 y 变量中的 0 值。如果响应变量中有 0,则无法将 GAMLSS 与 Gamma 分布拟合。

    警告:您示例中的代码不可重现,因此我无法理解在处理数据后您是否仍然在 y 变量中以 0 结束。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-17
      • 2019-05-04
      • 2016-04-30
      • 1970-01-01
      • 1970-01-01
      • 2016-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多