gpt4 book ai didi

gam - GAMLSS错误:响应变量超出范围

转载 作者:行者123 更新时间:2023-12-02 04:28:01 24 4
gpt4 key购买 nike

我无法理解为什么收到此错误。我的两个变量都是数字且长度相同,当变量不相同时,我用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个)

最佳答案

问题出在y变量的0值中。如果响应变量中为0,则无法使GAMLSS符合Gamma分布。

注意:示例中的代码不可复制,因此我无法理解在处理数据后,y变量是否仍为0。

关于gam - GAMLSS错误:响应变量超出范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51957993/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com