[R] issue running svyglm after subsetting: NA/NaN/Inf in foreign function call (arg 1)

Anthony Damico @jd@m|co @end|ng |rom gm@||@com
Fri Sep 30 15:05:06 CEST 2022


hi, that error happens before svyglm because the second parameter isn't a
logical test?  run `subset(rclus1, as.factor(stype=="E"))` and you'll see
the same error..  if you remove the "as.factor" `subset(rclus1,
(stype=="E"))`  then the svyglm simply fails to converge but i think that's
just too many variables without enough sample?  thanks




On Thu, Sep 29, 2022 at 4:18 PM Felippe Marcondes <
felippemarcondes using gmail.com> wrote:

> Hello,
>
> I am attempting to run 1 svyglm model for each of the levels of a factor
> variable.
> When I use the subset function in the survey design object, I get
> the following error:
>
> Error in qr.default(weights(design, "analysis"), tol = 1e-05) :
>   NA/NaN/Inf in foreign function call (arg 1)
>
> I am using the api data for a minimal reproducible example.
>
> # loading package and data
> library(survey)
> data(api)
>
> # creating the svyrep design object
> dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
>
> rclus1<-as.svrepdesign(dclus1)
>
>
> # attempting to sun svyglm model with subsetted design object:
> t <- svyglm(awards ~ comp.imp + api99 + api00 + cname + cnum + meals + ell,
> design = subset(rclus1, as.factor(stype=="E")), family = quasibinomial)
>
> I get the following error:
> Error in qr.default(weights(design, "analysis"), tol = 1e-05) :
>   NA/NaN/Inf in foreign function call (arg 1)
>
> How do I properly subset the design object by each level of the stype
> variable for the svyglm model to run?
>
> Thanks,
>
> Felippe
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list