Displaying 20 results from an estimated 100 matches similar to: "Package survey: Compute standard deviations from complex survey designs"
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
2010 Mar 10
1
Strange result in survey package: svyvar
Hi R users,
I'm using the survey package to calculate summary statistics for a large
health survey (the Demographic and Health Survey for Honduras, 2006), and
when I try to calculate the variances for several variables, I get negative
numbers. I thought it may be my data, so I ran the example on the help
page:
data(api)
## one-stage cluster sample
dclus1<-svydesign(id=~dnum, weights=~pw,
2012 Oct 18
3
svyplot and svysmooth with hexbin
Hi all-
So sorry to bother you all with something pretty basic.
I am trying to add the lines method output from svysmooth to a svyplot with style="grayhex". However, the line either appears in the wrong place or if I am running in R Studio it causes the system to crash.
I know this is something to do with Lattice graphics, but for the life of me I can not figure out how. Dr. Lumley
2016 Apr 30
0
Unexpected scores from weighted PCA with svyprcomp()
Hello!
I'd like to create an assets-based economic indicator using data from a
national household survey. The economic indicator is to be the first
principal component from a principal components analysis, which (given
the source of the data) I believe should take in consideration the
sampling weights of the observations. After running the PCA with
svyprcomp(), from the survey package, I
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,
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:
2011 Jul 22
1
Recoding Multiple Variables in a Data Frame in One Step
Hi, I can't for the life of me find how to do this in base R, but I'd be
surprised if it's not possible.
I'm just trying to replace multiple columns at once in a data frame.
#load example data
data(api)
#this displays the three columns and eight rows i'd like to replace
apiclus1[ apiclus1$meals > 98 , c( "pcttest" , "api00" , "sch.wide" ) ]
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
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
2003 Jul 21
1
Analysis of Complex Survey Data
Hi all
I would like to perform a logistic regression analysis on some complex survey data with R, but am not sure if there are functions within R that will
enable me to do so.
Also, are there any extensions of the "cor" function that would enable me to incorporate survey weights when calculating correlation coefficients for
bivariate data.
Any help on this matter will be greatly
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
2012 Jun 28
1
SVY: variance inflation factor VIF with complex survey
Hello,
Seeking a way to get the variance inflation factor VIF for a model of regression in complex survey, I have understood that without this package (SURVEY) RGui VIF obtained as follows:
fit <- lm(mpg~disp+hp+wt+drat, data=mtcars)
vif(fit)
But I want to know if survey, Vif is obtained so
vif( svyglm(api00~ell+meals+mobility, design=dstrat))
Thank you, happy day
2008 Jan 23
2
survey: estimating a covariance matrix
Hello
Does anybody happen to know if it is possible to use the survey package to
estimate a covariance matrix from a complex survey?
I have design weights and clusters (no strata), and want to get a covariance
matrix with preferably the effective sample size or else an estimate of the
variance-covariance matrix of the covariance matrix ("asymptotic covariance
matrix"). Is this
2008 Nov 30
1
using survey weights for correlations
Dear list,
I have a data file which includes, alongside various variables representing questionnaire scores, a variable for survey weights computed as the number of observations in the sample drawn from that group divided by the number of observations in the population in the group. I need to calculate a covariance matrix of the questionnaire scores for use in sem. How do I apply the weights?
2006 Apr 11
4
Bootstrap and Jackknife Bias using Survey Package
Dear R users,
I?m student of Master in Statistic and Data analysis, in New University of Lisbon. And now i?m writting my dissertation in variance estimation.So i?m using Survey Package to compute the principal estimators and theirs variances.
My data is from Incoming and Expendire Survey. This is stratified Multi-stage Survey care out by National Statistic Institute of Mozambique. My domain of
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
2014 Oct 15
2
Advice on package design for handling of dots in a formula
I am working on a new package, one in which the user needs to specify the
role that different variables play in the analysis. Where I'm stumped is the
best way to have users specify those roles.
Approach #1: Separate formula for each special component
First I thought to have users specify each formula separately, like:
new.function(formula=y~X1+X2+X3,
weights=~w,
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 ...)
Is this a version problem? I'm running R
2009 Dec 07
0
zelig logit survey
When I use zelig to compute parameter estimates with "model = logit.survey",
I receive the following error:
Nicholas Carnes. 2007. "logt.surveyWarning message:
In eval(expr, envir, enclose) : non-integer #successes in a binomial glm!
I believe this is because the model is not using "quasibinomial" (see R-News
2003, Analyzing Survey Data in R, by Thomas Lumley). Is there
2006 Feb 16
0
sums of absolute deviations about the median as split function in rpart
Dear R community,
as stated in Breiman et.al. (1984) and De'Ath & Fabricius (2000) using
sums of absolute deviations about the median as an impurity measure
gives robust trees.
I would like to use this method in rpart.
Has somebody already tried this method in rpart? Is there maybe already
a script available somewhere?
I am aware of the possibility to define usersplits myself with