1

我正在尝试使用 delta-lognormal GLM 对分布进行建模。我的数据是丰富的(大约 10% 零的连续变量)和一系列解释变量,但到目前为止我一次尝试一个。

head(data.file)

DENSITY    DEPTH  LONGITUDE LATITUDE  ...(ncol=8)

14.029843    172   9.325000  41.97000    
 8.557391    251   9.367333  42.33000  
17.235731    251   9.367333  42.33000    
37.262910    146   9.159500  42.30300    
19.829688    185   9.238333  42.31900   
... (nrow=12000)

我只找到了一个提供这种分析的包,fishMod. 我尝试了deltaLN()以下结果的命令。

deltaLN(DENSITY ~ DEPTH, ~DEPTH, data=data.file)

deltaLN(DENSITY ~ DEPTH, ~DEPTH, data=data.file) 中的错误:dims [product 12000] 与对象 [0] 的长度不匹配

知道这个错误代表什么以及如何修改它吗?否则,您是否知道其他提供 delta-lognormal GLM 的软件包?

4

1 回答 1

2

Package Developer here:这是代码中的错误。我的(愚蠢的)错误。它现在已针对包的 25 版(以及 R-3.1.0)进行了修复。请从现在开始使用它。

我在下面包含了一些示例代码,用于根据 Lucia 提供给我的数据进行调试。它包括上面提到的确切调用。

另一方面:您确定要使用增量对数正态模型吗?它们被包含在 fishMod 包中以保证“完整性”。我在下面的代码中包含了一个替代方案,一个 Tweedie GLM。根据数据和数据问题,您可能还需要考虑泊松伽马模型。有关详细信息,请参阅 Foster 和 Bravington (2013) Environ Ecol Stat (2013) 20:533-552。这是描述fishMod中方法的论文。

data.file <- read.csv("~/Desktop/data.file.csv") #will need to change on your machine

par( mfrow=c(1,3))

with( data.file, plot( DEPTH, DENSITY, pch=20, main="Raw Data"))
with( data.file, lines( lowess( DEPTH, DENSITY), col="red"))

require( fishMod)
fm.dln <- deltaLN( ln.form= DENSITY~DEPTH, binary.form=~DEPTH, data=data.file)
plot( fm.dln$fitted, fm.dln$residuals[,"quantile"], pch=20, main="Delta Log-Normal quantile residuals")
abline( h=0, col="red")

fm.Tweedie <- tglm( DENSITY~DEPTH, data=data.file)  #estimate power param too!
plot( fm.Tweedie$fitted, fm.Tweedie$residuals[,"random"], pch=20, main="Tweedie GLM Randomised quantile residuals")
abline( h=0, col="red")

#Tweedie has slightly better residuals, slightly only though.

example.model <- deltaLN(DENSITY ~ DEPTH, ~DEPTH, data=data.file) #to check the original problem, very directly.
于 2014-05-06T22:10:38.017 回答