當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


R Tweedie GAM 特威迪家族

R語言 Tweedie 位於 mgcv 包(package)。

說明

Tweedie 係列,設計用於與 mgcv 庫中的 gam 一起使用。限製為 1 到 2 之間的方差函數冪。當需要完全似然時,這是 quasi 的有用替代方案。 Tweedie 用於固定 ptw 用於在擬合期間估計 p 時。對於介於 1 和 2 之間的固定 p,Tweedie 是指數族分布,其方差由均值的冪 p 給出。

tw 隻能與 gambam 一起使用,但不能與 gamm 一起使用。 Tweedie 適用於所有三個。

用法

Tweedie(p=1, link = power(0))
tw(theta = NULL, link = "log",a=1.01,b=1.99)

參數

p

觀測值的方差與其均值的冪 p 成正比。 p 必須大於 1 且小於或等於 2。1 為泊鬆分布,2 為伽馬分布。

link

鏈接函數: "log""identity""inverse""sqrt"power 鏈接之一(僅限 Tweedie)。

theta

的 Tweedie 功率參數相關。如果以正值形式提供,則將其視為 p 的固定值。如果它是負值,則將其絕對值作為 p 的初始值。

a

用於優化的 p 的下限。

b

p 優化的上限。

細節

1<p<2 的 Tweedie 隨機變量是 N gamma 隨機變量的總和,其中 N 具有泊鬆分布。 p=1 的情況是泊鬆分布的推廣,並且是在尺度參數的整數倍上支持的離散分布。對於 1<p<2,分布在點質量為零的正實數上得到支持。 p=2 是伽瑪分布。當 p 非常接近 1 時,連續分布開始收斂於 p=1 時離散支持的極限,因此是高度多峰的。有關此行為的更多信息,請參閱ldTweedie

Tweedie 部分基於 poisson 係列,部分基於 statmod 包中的 tweedie。它包含可與所有 mgcv GAM 擬合方法以及 aic 函數配合使用的額外組件。

Tweedie 密度涉及一個沒有閉合形式的歸一化常數,因此使用 Dunn 和 Smyth (2005) 的級數評估方法進行評估,並進行擴展以計算關於 Tweedie 密度的導數。 p 和比例參數。如果不將 p 限製為 (1,2),Tweedie 密度的計算會更加困難,並且目前似乎沒有一種實現能夠比 quasi 提供任何優勢。如果您需要這種情況,那麽可以從 tweedie 包開始。

對於 Tweedie ,繼承自類 family 的對象,帶有附加元素

dvar

該函數給出方差函數的一階導數。 mu

d2var

該函數給出方差函數的二階導數。 mu

ls

返回 3 元素數組的函數:飽和對數似然值及其前 2 個導數。尺度參數。

對於 tw ,類 extended.family 的對象。

例子

library(mgcv)
set.seed(3)
n<-400
## Simulate data...
dat <- gamSim(1,n=n,dist="poisson",scale=.2)
dat$y <- rTweedie(exp(dat$f),p=1.3,phi=.5) ## Tweedie response

## Fit a fixed p Tweedie, with wrong link ...
b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=Tweedie(1.25,power(.1)),
         data=dat)
plot(b,pages=1)
print(b)

## Same by approximate REML...
b1 <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=Tweedie(1.25,power(.1)),
          data=dat,method="REML")
plot(b1,pages=1)
print(b1)

## estimate p as part of fitting

b2 <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=tw(),
          data=dat,method="REML")
plot(b2,pages=1)
print(b2)

rm(dat)

作者

Simon N. Wood simon.wood@r-project.org.

參考

Dunn, P.K. and G.K. Smyth (2005) Series evaluation of Tweedie exponential dispersion model densities. Statistics and Computing 15:267-280

Tweedie, M. C. K. (1984). An index which distinguishes between some important exponential families. Statistics: Applications and New Directions. Proceedings of the Indian Statistical Institute Golden Jubilee International Conference (Eds. J. K. Ghosh and J. Roy), pp. 579-604. Calcutta: Indian Statistical Institute.

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

也可以看看

ldTweedie , rTweedie

相關用法


注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 GAM Tweedie families。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。