Gamma regression with weights using glm Is there anyway to give weights to a gamma regression so that the variance is allowed to be different, dependent on a particular parameter(in this case sampling event)?
When I try to run my code :
Nm5<-glm(myformula,family=Gamma,data=master_mr,weights=varIdent(form=~1| fevent))

I get this error:
Error in model.frame.default(formula = myformula)
variable lengths differ (found for '(weights)'

When I run the following code (same thing only with gls), it runs fine, except I am now not using a Gamma distribution.
Nm2<-gls(myformula,weights=varIdent(form=~1| fevent),data=master_mr)

You can use the weights function with glm, but not in conjunction with Gamma.  I found an example (slide 30ish) where it is done, but the code doesn't make sense to me and also doesn't work the way I would expect. This leads me to believe that it can be done. Any ideas?
 A: This actually is more an R programming question than a statistics question.  But I'll bite.  The function gls belongs to package 'nlme', as does varIdent.  The function glm belongs the package (well namespace, really) 'stats', which actually is just part of base R.  To see this type ?gls and look in the topmost line to see what package is listed.
Anyways, it's maybe an unhappy design choice that the "weights" argument is overloaded for gls.  Or maybe not.  But in any case, glm doesn't know how to use the varClasses in gls for any of its routines.  Accomodating them results in a much different and more complicated model that would require a different fitting procedure than employed by glm.
On a different note, the model you are trying to estimate is ambiguous, at least to me.  The gamma glm assumes that the variance is equal to the square of the mean, times a dispersion parameter.  So I can only assume that you want to model the dispersion parameter as a function of covariates, but maybe you have something else in mind.  I would call such a model a vector generalized linear model.  The package VGAM can fit many different flavors of these--maybe even gamma with varying dispersion.
