Displaying 20 results from an estimated 25 matches for "svyby".
Did you mean:
mayby
2006 Aug 21
1
"vcov" error in svyby and svytable functions
Hi,
I'm trying to compute survey svytable statistic on subsets by using the
svyby function.
Here is the code:
b<-svyby(~V024+V751, by=~V025, design=strat2, svytable, round=TRUE)
The vars, V024, V751 and V025 are factors. The by var has 2 levels, and
hence there will be two subsets. strat2 is created by the svydesign function.
It's giving me the following error:
> b...
2010 Aug 18
1
svyquantile w/ svyby is returning an error
svymean w/ svyby is working for me...
> svyby(~visitcnt, ~agegrp3.f, svymean, design=svydes)
agegrp3.f visitcnt se.visitcnt
18-44 18-44 8.755552 0.4953235
45-64 45-64 10.131555 0.5347806
65+ 65+ 9.588802 0.4323629
svyquantile is working for me...
> svyquantile(~visitcnt, quan...
2012 Apr 13
2
problem with svyby and NAs (survey package)
...1998 17890 1921
1999 18322 1669
2001 17623 2122
...
Note some years are missing - they are part of the dataset, but all
responses are NA (the question wasn't asked).
However, this gives an error, and I'd like to understand why - it works
for variables without missing years:
svyby(~problem.vandal, ~SurvYear, seh.dsn, svymean, na.rm=TRUE)
Error in tapply(1:NROW(x), list(factor(strata)), function(index) { :
arguments must have same length
The error only occurs when na.rm=TRUE and there are no observations in
one year.
Thanks
alex
Please access the attached hyperlink for...
2006 Apr 22
1
svyby example returns error
I get error trying to run examples from 'svyby' help page (?svyby in
package "Survey"):
# code
data(api)
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
svyby(~api99, ~stype, dclus1, svymean)
# error message
> Error in match.arg(vartype, several.ok = TRUE) :
unused argument(s) (several.ok ...)...
2010 Jun 03
1
problem with 'svyby' function from SURVEY package
...ity-weighted outcome variable means for the different levels of covariate. So I first define the structure of the study design (I'm using the CDC's NHANES data):
dhanes <- svydesign(id=~PSU, strat=~STRATA, weight=~lab_weight, data=final, nest=TRUE)
No problem there.
Now I use the "svyby" function as follows:
svyby(~outcome, ~covariate, design=dhanes, svymean, na.rm=T) -> haha
print(haha)
covariate outcome se.outcome
1 1 0.4961189 0.08828457
2 2 0.4474706 0.22214557
3 3 0.5157026 0.12076008
4 4 0.6773910 0.20605025
NA NA 0.8...
2012 Oct 02
2
svyby and make.formula
Hello,
Although my R code for the svymean () and svyquantile () functions works fine, I am stuck with the svyby () and make.formula () functions. I got the following error messages.
- Error: object of type 'closure' is not subsettable # svyby ()
- Error in xx[[1]] : subscript out of bounds # make.formula ()
A reproducible example is appended below.
I would appreciate if someone cou...
2011 Mar 07
1
Risk differences with survey package
I'm trying to use the survey package to calculate a risk difference with
confidence interval for binge drinking between sexes. Variables are
X_RFBING2 (Yes, No) and SEX. Both are factors. I can get the group
prevalences easily enough with
result <- svyby(~X_RFBING2, ~SEX, la04.svy, svymean, na.rm = TRUE)
and then extract components from the svyby object with SE() and coef() to
do the computations. This gives the correct results, but I'd like to set
this up as a contrast and am having difficulty. What is the best way to do
it?
Thanks!
2008 Oct 22
1
Package survey
Hi,
I’m using the svyby for total statistics, for example:
svyby(~p_igov,~div_a,desenho_nps,svytotal,drop.empty.groups=TRUE,vartype
=c("se","var","cvpct"))
In the numerical variable p_igov (and others) I have many non responses
but if I maintain the NA it doesn’t work.
summary(bas...
2010 Mar 26
1
return.replicates in survey pkg
How do I retrieve the replicates estimates from a crosstab done using
svyby?
Here is an example from the help page for svyby in the package:
> data(api)
> dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
> rclus1<-as.svrepdesign(dclus1)
>
> a <- svyby(~api99, ~stype, rclus1, svymean, return.replicates=TRUE)
> a$replicates
NULL...
2017 Jul 09
2
Help with ftable.svyby
Hi all,
When I try the following with pkg Survey it returns the error below:
ftable(svyby(~INCOME, ~AGECL+RACECL, svymean, design=q50),
rownames=list(AGECL=c("<35", "35-44", "45-54", "55-64",
"65-74", ">=75"),
RACECL=c("white non hispanic", "non...
2009 Mar 11
1
CI from svyquantile in survey package
...om
the survey package. I am using R version 2.8.1 (2008-12-22) and survey
package (3.11-2) on FC7 linux. To simplify my question I use an example from
that package:
R> data(api)
R> dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
R> (tst <- svyby(~api99, ~stype, dclus1, svyquantile,
quantiles=0.5,ci=TRUE))
stype api99 se
E E 615 37.89
H H 593 69.52
M M 611 37.67
R> str(tst)
Classes ???svyby??? and 'data.frame': 3 obs. of 3 variables:
$ stype: Factor w/ 3 levels "E&q...
2017 Jul 09
0
Help with ftable.svyby
..., INCOME = factor( INCOME ) , AGECL = factor( AGECL ) ,
RACECL = factor( RACECL ) )
On Sun, Jul 9, 2017 at 2:59 PM, Orsola Costantini via R-help <
r-help at r-project.org> wrote:
> Hi all,
>
> When I try the following with pkg Survey it returns the error below:
>
> ftable(svyby(~INCOME, ~AGECL+RACECL, svymean, design=q50),
> rownames=list(AGECL=c("<35", "35-44", "45-54", "55-64",
> "65-74", ">=75"),
> RACECL=c("white non hispanic&q...
2010 Feb 18
1
survey package question
Should the svyby function be able to work with svyquantile? I get the
error below ...
data(api)
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
svyby(~api00,
design=dclus1,
by = ~stype,
quantiles=c(.25,.5,.75),
FUN=svyquantile,
na.rm=T
)...
2012 Aug 10
1
Direct Method Age-Adjustment to Complex Survey Data
...ata = ~SDMVSTRA ,
nest = TRUE ,
weights = ~WTMEC2YR ,
data = x
)
# only perform analyses among individuals aged 20 and over
z <- subset( y , RIDAGEYR >= 20 )
# these four commands calculate the correct non-age-adjusted estimate
svymean( ~HI_CHOL , z , na.rm = T )
svyby( ~HI_CHOL , ~race , z , svymean , na.rm = T )
svyby( ~HI_CHOL , ~RIAGENDR , z , svymean , na.rm = T )
svyby( ~HI_CHOL , ~RIAGENDR+race , z , svymean , na.rm = T )
# but matching the figure exactly requires an exact age adjustment.
# create the population types vector
pop.types <-
data.frame...
2010 Aug 25
1
Surprising behaviour survey-package with missing values
...(
id = 1:20,
stratum = rep(c("a", "b"), each=10),
income = rnorm(20, 100),
n = rep(c(100, 200), each=10)
)
data$income[5] <- NA
# calculate mean and total income for every stratum using survey package
des <- svydesign(ids=~id, strata=~stratum, data=data, fpc=~n)
svyby(~income, by=~stratum, FUN=svytotal, design=des, na.rm=TRUE)
mn <- svyby(~income, by=~stratum, FUN=svymean, design=des, na.rm=TRUE)
mn
n <- svyby(~n, by=~stratum, FUN=svymean, design=des)
# total does not equal mean times number of persons in stratum
mn[2] * n[2]
# calculate mean and tota...
2011 Aug 18
1
Comparison of means in survey package
...arty=sample(c("BQ", "NDP", "Conservative", "Liberal", "None", NA), size=500, replace=TRUE), natwgt=sample(c(0.88, 0.99, 1.43, 1.22, 1.1), size=500, replace=TRUE), gender=sample(c("Male", "Female"), size=500, replace=TRUE))
Using svyby I can get the means for each group of interest (primarily the party variable), but I can't get further to actually do the comparison of means. I saw a reference on the help listserv to the effect that the survey package does not do ttests and that one should use svyglm. However, that was in 2...
2011 Aug 28
4
How do I get a weighted frequency table?
? stato filtrato un testo allegato il cui set di caratteri non era
indicato...
Nome: non disponibile
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110828/d35f51a1/attachment.pl>
2009 Nov 14
4
Weighted descriptives by levels of another variables
I've noticed that R has a number of very useful functions for
obtaining descriptive statistics on groups of variables, including
summary {stats}, describe {Hmisc}, and describe {psych}, but none that
I have found is able to provided weighted descriptives of subsets of a
data set (ex. descriptives for both males and females for age, where
accurate results require use of sampling
2006 Feb 17
3
Windows metafile problem
Hi All:
I'm using win.metafile() to produce windows metafiles.
When I use Word to insert the wmf picture, Word gives an error!
I did my homework in posting this question, and couldn't find a fix.
Any suggestions?
Phil Smith
CDC
2007 Sep 20
2
Package Survey
Hello,
How I use the function as.svrepdesign without memory.size problems?
desenho_npc_JK <- as.svrepdesign(desenho_npc,type="JKn")
Error: cannot allocate vector of size 161.3 Mb
In addition: Warning messages:
1: Reached total allocation of 1022Mb: see help(memory.size)
2: Reached total allocation of 1022Mb: see help(memory.size)
3: Reached total allocation of 1022Mb: