Skip to content
Prev 67488 / 398525 Next

calling svydesign function that uses model.frame

On Mon, 11 Apr 2005, Richard Valliant wrote:

            
<snip>
Two possibilities
1/ construct a formula with as.formula and paste
svydesign(id=as.formula(paste("~",new.psu)), strata=as.formula(paste("~",str.col)),...)

For a working example
1 - level Cluster Sampling design
With (15) clusters.
svydesign(id = as.formula(paste("~", psu)), weight = ~pw, data = apiclus1)

2/ use substitute()
A working example:
list(id=as.name(psu))))
1 - level Cluster Sampling design
With (15) clusters.
svydesign(id = ~dnum, weight = ~pw, data = apiclus1)


As you can see, the second option is probably more cumbersome but has the 
advantage of producing a prettier-looking call.

 	-thomas