[R] Fitting a Tweedie distribution

David Winsemius dwinsemius at comcast.net
Fri Jan 2 20:59:24 CET 2015


On Jan 2, 2015, at 10:33 AM, Paul Hudson wrote:

> Hello all,
> 
> I want to fit a tweedie distribution to the data I have.
> 
> The R packages I have been able to find assume that I want to use it as
> part as of a generalized linear model.
> 
> This is not the case, I want to directly fit the distribution to the data.
> 
> Is there a package that allows this?

install.packages("sos")
findFn("tweedie")
#Scrolling down the resulting page, I do see a 'tweedie' package.
require(tweedie)  # has the rtweedie function
y <- rtweedie(100, xi=1.5, mu=20, phi=3)
help(pack=tweedie)  # Bottom of page says tweedie.profile will estimate power

res <- tweedie.profile(y~1)
#1.2 1.3 1.4 1.5 1.6 1.7 1.8 
#.......Done.
 str(res)

#-------------
List of 12
 $ y         : num [1:50] -410 -408 -406 -405 -403 ...
 $ x         : num [1:50] 1.2 1.21 1.22 1.24 1.25 ...
 $ ht        : num -396
 $ L         : num [1:7(1d)] -410 -399 -395 -394 -395 ...
 $ xi        : num [1:7] 1.2 1.3 1.4 1.5 1.6 1.7 1.8
 $ xi.max    : num 1.49
 $ L.max     : num -394
 $ phi       : num [1:7(1d)] 4.85 4.16 3.43 2.8 2.3 ...
 $ phi.max   : num 2.83
 $ ci        : num [1:2(1d)] 1.37 1.62
 $ method    : chr "inversion"
 $ phi.method: chr "mle"

Seems to estimate both the power and dispersion parameters reasonably well.


> 
> 	[[alternative HTML version deleted]]

This is a plain-text mailing list.

-- 

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list