Displaying 20 results from an estimated 500 matches similar to: "Question on survey package"
2006 May 23
1
Survey proportions... Can I use population as denominator?
Just giving the survey package a spin...
I'm accustomed to stata, and it seems very similar in many respects. One
thing is throwing me, however.
I've gotten my data in, and specified the design. Looks like the weighting
is right (based on published population estimates from these data), but now
I'd like to check my "marginal means" for proportions against those that
have
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
But, compare to
> 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, quantiles=c(.25, .5, .75), ties="rounded", design=svydes)
0.25
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
)
> Error in object$coefficients : $ operator is invalid for atomic
vectors
A
2012 Sep 21
1
Exactly Replicating Stata's Survey Data Confidence Intervals in R
Hi everyone, apologies if the answer to this is in an obvious place. I've
been searching for about a day and haven't found anything..
I'm trying to replicate Stata's confidence intervals in R with the survey
package, and the numbers are very very close but not exact. My ultimate
goal is to replicate Berkeley's SDA website with R (http://sda.berkeley.edu/),
which seems to
2005 Jun 16
1
Survey - Cluster Sampling
Dear WizaRds,
I am struggling to compute correctly a cluster sampling design. I want
to do one stage clustering with different parametric changes:
Let M be the total number of clusters in the population, and m the
number sampled. Let N be the total of elements in the population and n
the number sampled. y are the values sampled. This is my example data:
clus1 <-
2009 Mar 11
1
CI from svyquantile in survey package
I am having trouble understanding (i.e. getting) confidence intervals from
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,
2013 May 02
1
Package survey: singularities in linear regression models
Hello,
I want to specify a linear regression model in which the metric outcome
is predicted by two factors and their interaction. glm() computes
effects for each factor level and the levels of the interaction. In the
case of singularities glm() displays "NA" for the corresponding
coefficients. However, svyglm() aborts with an error message. Is there a
possibility that svyglm()
2012 Jun 21
4
crosstable and regression for survey data (weighted)
I have survey data that I am working on. I need to make some multi-way tables
and regression analyses on the data. After attaching the data, this is the
code I use for tables for four variables (sweight is the weight variable):
> a <- xtabs(sweight~research.area + gender + a2n2 + age)
> tmp <- ftable(a)
Is this correct? I don't think I need to use the strata and cluster
2009 Nov 02
2
"object not found" within function
Hi,
I am trying to write a function to compute many cross-tabulations with the -svytable- command. Here is a simplified example of the structure of my code (adapted from the -svytable- help file):
data(api)
func.example<-function(variable){
dclus1<-svydesign(id=~1, weights=~pw,data=apiclus1, fpc=~fpc)
svytable(~ variable, dclus1)
}
When I call this function with:
2006 Jun 18
1
Post Stratification
Dear WizaRds,
having met some of you in person in Vienna, I think even more fondly
of this community and hope to continue on this route. It was great
talking with you and learning from you. Thank you. I am trying to work
through an artificial example in post stratification. This is my dataset:
library(survey)
age <- data.frame(id=1:8, stratum=rep(
2007 Sep 06
3
Survey package
Good afternoon!
I'm trying to use the Survey package for a stratified sample which has 4 criteria on which the stratification is based. I would like to get the corrected weights and for every element i get a weight of 1
E.g: tipping
design <- svydesign (id=~1, strata= ~regiune + size_loc + age_rec_hhh + size_hh, data= tabel)
and then weights(design)
gives
2008 Jan 25
3
function code
R-help,
Sorry for this question (I guess it has been addressed before but
I could not find it in the archives)
but how can I see a function code
when the following comes up:
> svymean
function (x, design, na.rm = FALSE, ...)
{
.svycheck(design)
UseMethod("svymean", design)
}
<environment: namespace:survey>
Thanks in advance
2005 May 26
1
Survey and Stratification
Dear WizaRds,
Working through sampling theory, I tried to comprehend the concept of
stratification and apply it with Survey to a small example. My question
is more of theoretic nature, so I apologize if this does not fully fit
this board's intention, but I have come to a complete stop in my efforts
and need an expert to help me along. Please help:
age<-matrix(c(rep(1,5), rep(2,3),
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
2011 Oct 24
4
Problem with svyvar in survey package
I am facing a problem with a function in survey package. The function svyvar
gives the estimated population variance from a given sampling scheme. I am
working with a data having more than four continuous variables. In order to
have have population total for all those cont. variables I have written in
the following format
svyvar(~var1+var2+var3+var4+var5+var6,data) ; var1,var2,...,var6 are 6
2003 Feb 12
2
Various Errors using Survey Package
Hi,
I have been experimenting with the new Survey package. Specifically, I was
trying to use some of the functions on the public-use survey data from NHIS
(2000 Sample Adult file).
Error 1): The first error I get is when I try to specify the complex survey
design.
nhis.design<-svydesign(ids=~psu, probs=~probs, strata=~strata, data=nhis.df,
check.strata=TRUE)
Error in svydesign(ids =
2008 Aug 15
2
Design-consistent variance estimate
Dear List:
I am working to understand some differences between the results of the
svymean() function in the survey package and from code I have written
myself. The results from svymean() also agree with results I get from
SAS proc surveymeans, so, this suggests I am misunderstanding something.
I am never comfortable with "I did what the software" does mentality, so
I am working to
2003 Feb 19
5
Subpopulations in Complex Surveys
Hi,
is there a way to analyze subpopulations (e.g. women over 50, those who
answered "yes" to a particular question) in a survey using Survey package?
Other packages (e.g. Stata, SUDAAN) do this with a subpopulation option to
identify the subpopulation for which the analysis shoud be done. I did not
see this option in the Survey package. Is there another way to do this?
2012 Apr 13
2
problem with svyby and NAs (survey package)
Hello
I'm trying to get the proportion "true" for dichotomous variable for
various subgroups in a survey.
This works fine, but obviously doesn't give proportions directly:
svytable(~SurvYear+problem.vandal, seh.dsn, round=TRUE)
problem.vandal
SurvYear FALSE TRUE
1995 8906 786
1997 17164 2494
1998 17890 1921
1999 18322 1669
2001 17623 2122
...