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

Felippe Marcondes |e||ppem@rconde@ @end|ng |rom gm@||@com
Thu Sep 29 16:55:56 CEST 2022


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]]



More information about the R-help mailing list