ziP
位於 mgcv
包(package)。 說明
係列與 gam
或 bam
一起使用,當零概率的互補對數對數線性依賴於泊鬆參數的對數時,實現零膨脹泊鬆數據的回歸。請務必小心使用,請注意,僅僅具有許多零響應觀測值並不表示零膨脹:問題是在給定指定模型的情況下是否有太多零。
這種模型實際上僅適用於沒有任何協變量有助於解釋數據中的零的情況。如果您的協變量預測哪些觀測值可能具有零均值,那麽在此基礎上添加零膨脹模型可能會導致可識別性問題。可識別性問題可能會導致擬合失敗,或者導致線性預測變量或預測值出現荒謬的值。
用法
ziP(theta = NULL, link = "identity",b=0)
參數
theta |
控製零通脹率的均值線性變換的斜率和截距的 2 個參數。如果提供則視為固定參數( 和 ),否則進行估計。 |
link |
鏈接函數:目前僅支持 |
b |
非負常數,指定零通脹率對線性預測變量的最小依賴性。 |
細節
零計數的概率由 theta
參數與平滑參數一起進行估計。從零開始增加 b
參數可以大大減少可識別性問題,特別是當非零數據很少時。 給出,而計數的概率 由截斷的泊鬆概率函數 給出。線性預測器給出 ,而 和 。
該模型的擬合值為泊鬆參數的對數。將 predict
函數與 type=="response"
結合使用以獲得預測的預期響應。請注意,模型摘要中報告的 theta 參數為 和 。
這些模型應該經過非常仔細的檢查,特別是在擬合尚未收斂的情況下。建立具有可識別性問題的模型非常容易,特別是如果數據不是真正的零膨脹,而隻是有許多零,因為協變量空間的某些部分的均值非常低。請參閱示例以了解一些明顯的檢查。認真對待收斂警告。
值
類 extended.family
的對象。
警告
零膨脹模型通常是over-used。數據中存在大量零本身並不意味著通貨膨脹為零。 *考慮到模型平均值*,有太多零可能意味著零通脹。
例子
rzip <- function(gamma,theta= c(-2,.3)) {
## generate zero inflated Poisson random variables, where
## lambda = exp(gamma), eta = theta[1] + exp(theta[2])*gamma
## and 1-p = exp(-exp(eta)).
y <- gamma; n <- length(y)
lambda <- exp(gamma)
eta <- theta[1] + exp(theta[2])*gamma
p <- 1- exp(-exp(eta))
ind <- p > runif(n)
y[!ind] <- 0
np <- sum(ind)
## generate from zero truncated Poisson, given presence...
y[ind] <- qpois(runif(np,dpois(0,lambda[ind]),1),lambda[ind])
y
}
library(mgcv)
## Simulate some ziP data...
set.seed(1);n<-400
dat <- gamSim(1,n=n)
dat$y <- rzip(dat$f/4-1)
b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=ziP(),data=dat)
b$outer.info ## check convergence!!
b
plot(b,pages=1)
plot(b,pages=1,unconditional=TRUE) ## add s.p. uncertainty
gam.check(b)
## more checking...
## 1. If the zero inflation rate becomes decoupled from the linear predictor,
## it is possible for the linear predictor to be almost unbounded in regions
## containing many zeroes. So examine if the range of predicted values
## is sane for the zero cases?
range(predict(b,type="response")[b$y==0])
## 2. Further plots...
par(mfrow=c(2,2))
plot(predict(b,type="response"),residuals(b))
plot(predict(b,type="response"),b$y);abline(0,1,col=2)
plot(b$linear.predictors,b$y)
qq.gam(b,rep=20,level=1)
## 3. Refit fixing the theta parameters at their estimated values, to check we
## get essentially the same fit...
thb <- b$family$getTheta()
b0 <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=ziP(theta=thb),data=dat)
b;b0
## Example fit forcing minimum linkage of prob present and
## linear predictor. Can fix some identifiability problems.
b2 <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=ziP(b=.3),data=dat)
作者
Simon N. Wood simon.wood@r-project.org
參考
Wood, S.N., N. Pya and B. Saefken (2016), Smoothing parameter and model selection for general smooth models. Journal of the American Statistical Association 111, 1548-1575 doi:10.1080/01621459.2016.1180986
也可以看看
相關用法
- R ziplss 零膨脹(跨欄)泊鬆位置比例模型係列
- R vcov.gam 從 GAM 擬合中提取參數(估計器)協方差矩陣
- R gam.check 擬合 gam 模型的一些診斷
- R null.space.dimension TPRS 未懲罰函數空間的基礎
- R gam.reparam 尋找平方根懲罰的穩定正交重新參數化。
- R extract.lme.cov 從 lme 對象中提取數據協方差矩陣
- R scat 用於重尾數據的 GAM 縮放 t 係列
- R choldrop 刪除並排名第一 Cholesky 因子更新
- R smooth.construct.cr.smooth.spec GAM 中的懲罰三次回歸樣條
- R bandchol 帶對角矩陣的 Choleski 分解
- R gam.side GAM 的可識別性邊條件
- R cox.ph 附加 Cox 比例風險模型
- R mgcv.parallel mgcv 中的並行計算。
- R gamm 廣義加性混合模型
- R pdTens 實現張量積平滑的 pdMat 類的函數
- R Predict.matrix GAM 中平滑項的預測方法
- R Predict.matrix.soap.film 皂膜光滑度預測矩陣
- R smooth.construct.bs.smooth.spec GAM 中的懲罰 B 樣條
- R gamlss.gH 計算回歸係數的對數似然導數
- R plot.gam 默認 GAM 繪圖
- R mvn 多元正態加性模型
- R gfam 分組家庭
- R smooth.construct GAM 中平滑項的構造函數
- R pcls 懲罰約束最小二乘擬合
- R gam.fit3 使用 GCV、UBRE/AIC 或 RE/ML 導數計算進行 P-IRLS GAM 估計
注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 GAM zero-inflated (hurdle) Poisson regression family。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。