weights error in svyglm

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

weights error in svyglm

Laura Lee
Hi!

I am just learning the 'svyglm' package and have run into an error for which I have not found a solution. My data have been collected from a stratified random survey. Here is the code:

NB3<-glm.nb(COLNUM~Year+Depth+MESH+offset(LogEffort),data=data)

dstrat <- svydesign(id=~1, strata=~STRATA, weights = ~weight, data=data)

SNB3 <- svyglm(NB3, design=dstrat)

The error that is returned is:

Error in model.frame.glm(formula = list(coefficients = c(-6.96858807641624,  :
  object '.survey.prob.weights' not found

I would appreciate any assistance in solving this problem.

Thanks,

Laura


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Laura M. Lee
Senior Stock Assessment Scientist
North Carolina Division of Marine Fisheries
E-Mail: laura.lee@ncdenr.gov
Reply | Threaded
Open this post in threaded view
|

Re: weights error in svyglm

Milan Bouchet-Valat
Le vendredi 11 avril 2014 à 13:38 +0000, Lee, Laura a écrit :

> Hi!
>
> I am just learning the 'svyglm' package and have run into an error for
> which I have not found a solution. My data have been collected from a
> stratified random survey. Here is the code:
>
> NB3<-glm.nb(COLNUM~Year+Depth+MESH+offset(LogEffort),data=data)
>
> dstrat <- svydesign(id=~1, strata=~STRATA, weights = ~weight,
> data=data)
>
> SNB3 <- svyglm(NB3, design=dstrat)
>
> The error that is returned is:
>
> Error in model.frame.glm(formula = list(coefficients =
> c(-6.96858807641624,  :
>   object '.survey.prob.weights' not found
>
> I would appreciate any assistance in solving this problem.
The error is somewhat strange, but you should not pass the result of
glm.nb() to svyglm (where have you found this idea?). Just do
SNB3 <- svyglm(COLNUM ~ Year + Depth + MESH + offset(LogEffort), design=dstrat)


Regards

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: weights error in svyglm

Laura Lee
Thanks! That worked. However, what error distribution is assumed? I was hoping to use a negative binomial.

-----Original Message-----
From: Milan Bouchet-Valat [mailto:[hidden email]]
Sent: Friday, April 11, 2014 11:37 AM
To: Lee, Laura
Cc: [hidden email]
Subject: Re: [R] weights error in svyglm

Le vendredi 11 avril 2014 à 13:38 +0000, Lee, Laura a écrit :

> Hi!
>
> I am just learning the 'svyglm' package and have run into an error for
> which I have not found a solution. My data have been collected from a
> stratified random survey. Here is the code:
>
> NB3<-glm.nb(COLNUM~Year+Depth+MESH+offset(LogEffort),data=data)
>
> dstrat <- svydesign(id=~1, strata=~STRATA, weights = ~weight,
> data=data)
>
> SNB3 <- svyglm(NB3, design=dstrat)
>
> The error that is returned is:
>
> Error in model.frame.glm(formula = list(coefficients =
> c(-6.96858807641624,  :
>   object '.survey.prob.weights' not found
>
> I would appreciate any assistance in solving this problem.
The error is somewhat strange, but you should not pass the result of
glm.nb() to svyglm (where have you found this idea?). Just do
SNB3 <- svyglm(COLNUM ~ Year + Depth + MESH + offset(LogEffort), design=dstrat)


Regards
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Laura M. Lee
Senior Stock Assessment Scientist
North Carolina Division of Marine Fisheries
E-Mail: laura.lee@ncdenr.gov
Reply | Threaded
Open this post in threaded view
|

Re: weights error in svyglm

Milan Bouchet-Valat
In reply to this post by Milan Bouchet-Valat
Le vendredi 11 avril 2014 à 15:54 +0000, Lee, Laura a écrit :
> Thanks! That worked. However, what error distribution is assumed? I
> was hoping to use a negative binomial.
Since svyglm() computes designed-based standard errors, you should be
able to simply pass family=poisson instead. See
books.google.fr/books?id=L96ludyhFBsC&pg=SA10-PA44
and following sections.


Regards

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.