[R] Help converting a function from S-Plus to R: family$weight
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Aug 13 11:07:53 CEST 2005
I think a question about the S family() functions is best determined by
reading the S(-PLUS) documentation. The weights component computes the
working weights for the IWLS, unsurprisingly (and as stated by
?family.object). R has mu.eta to do that, the crucial line in R's glm.fit
being
w <- sqrt((weights[good] * mu.eta.val[good]^2)/variance(mu)[good])
But you don't need to port S-only features to R. You do need to worry
about R-only features.
On Fri, 12 Aug 2005, Peter Dunn wrote:
> Hi all
>
> I am converting an S-Plus function into R. The S-Plus code
> uses some of the glm families, and family objects.
>
> The family objects in S-Plus and R have many different
> features, for example:
>
> In R:
> > names(Gamma())
> [1] "family" "link" "linkfun" "linkinv" "variance"
> [6] "dev.resids" "aic" "mu.eta" "initialize" "validmu"
> [11] "valideta"
>
> In S-Plus:
> > names(Gamma())
> [1] "family" "names" "link" "inverse" "deriv"
> [6] "initialize" "variance" "deviance" "weight"
> >
>
>
> My question concerns the variable weight in the S-Plus function.
> I'm not sure what it is. (I have searched the S-Plus mailing list
> archive, and my "S-Plus for linux 6.1" documentation.) For almost all
> family objects, the weight variable is the same as variance,
> just weighted (and the former as a function; the later as an
> expression):
>
> > Gamma()$variance
> function(mu)
> mu^2
> > Gamma()$weight
> expression(w * mu^2.)
> >
>
> The same applies for most families. So I thought I could determine
> what this weight variable was.
>
> But alas--not the inverse,gaussian:
>
> > inverse.gaussian()$variance
> function(mu)
> mu^3
> > inverse.gaussian()$weight
> expression(w/((sqrt(family$variance(mu)) * family$deriv(mu))^2.))
>
>
> So:
> - can anyone tell me what this expression weight represents?
> - why is the inverse.gaussian family different than all others?
>
> Thanks in advance.
>
> P.
>
> My S-Plus version:
>
> > version
> Version 6.2.1 for Linux 2.4.18 : 2003
>
> My R version:
>
> > version
> _
> platform i386-pc-linux-gnu
> arch i386
> os linux-gnu
> system i386, linux-gnu
> status
> major 2
> minor 1.0
> year 2005
> month 04
> day 18
> language R
> >
>
>
> --
> Dr Peter Dunn | Senior Lecturer in Statistics
> Faculty of Sciences, University of Southern Queensland
> Web: http://www.sci.usq.edu.au/staff/dunn
> Email: dunn <at> usq.edu.au
> CRICOS: QLD 00244B | NSW 02225M | VIC 02387D | WA 02521C
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list