search for: dclus1

Displaying 17 results from an estimated 17 matches for "dclus1".

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: func.example(api99) I get the following error: Error in eval(expr, envir, enclos) : object 'variable' not found. (Everything works fine when I type svytable(...
2012 Sep 21
1
Exactly Replicating Stata's Survey Data Confidence Intervals in R
...# simple example using example code pulled from ?svymean options(digits=20) library(survey) library(foreign) # read the data file from a website, to make sure you're using the same data in both R and stata x <- read.dta( "http://www.ats.ucla.edu/stat/stata/library/apiclus1.dta" ) dclus1<-svydesign(id=~dnum, fpc=~fpc, data=x) # mean matches exactly coef(svymean(~I(ell==0), dclus1)) # SE matches exactly SE(svymean(~I(ell==0), dclus1)) # design df matches exactly degf(dclus1) # unwtd count matches exactly unwtd.count( ~ell, dclus1) # wtd count matches exactly svytotal( ~!is.n...
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, 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?...
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 more g...
2010 Mar 10
1
Strange result in survey package: svyvar
...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, data=apiclus1, fpc=~fpc) svyvar(~api00+enroll+api.stu+api99, dclus1) variance SE api00 11182.8 1386.4 api00 11516.3 1412.9 api.stu -4547.1 3164.9 api99 12735.2 1450.1 If I look at the full matrix for the variances (and covariances): test&...
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 <- svymean(~api99, design=rclus1, return.replicates=TRUE) > b$r...
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
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
2004 Sep 02
1
Question on survey package
Is there a way to use one of the functions in the survey package to get a table of estimated percentages (or proportions) and the standard error for each? For example, suppose that AGECODE AND SEX are two factors with 5 and 2 levels. The 5x2 AGECODE x SEX table would have the estimated percentage of persons in each cell, 100*(sum of weights in the cell) / (sum of all weights) and the std
2005 Jun 16
1
Survey - Cluster Sampling
...elements in the population and n the number sampled. y are the values sampled. This is my example data: clus1 <- data.frame(cluster=c(1,1,1,2,2,2,3,3,3), id=seq(1:3,3), weight=rep(72/9,9), nl=rep(3,9), Nl=rep(3,9), N=rep(72,9), y=c(23,33,77, 25,35,74, 27,37,72) ) 1. Let M=m=3 and N=n=9. Then: dclus1<-svydesign(id=~cluster, data=clus1) svymean(~y, dclus1) mean SE y 44.778 0.294, the unweighted mean, assuming equal probability in the clusters. ok. 2. Let M=23, m=3 and N=72, n=9, then I am unable to use svydesign correctly: dclus2<-svydesign(id=~cluster, data=clus1, fpc=~N) svy...
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
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 Version 2.1.0 (2005-04-18, i386-pc-...
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
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()
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
2012 Oct 16
1
Package survey: Compute standard deviations from complex survey designs
Hello, svyvar from the survey package computes variances (with standard errors) from survey design objects. Is there any way to compute standard deviations and their standard errors in a similar manner? Thanks a lot, Sebastian
2012 Aug 31
2
test Breslow-Day for svytable??
Hi all, I want to know how to perform the test Breslow-Day test for homogeneity of odds ratios (OR) stratified for svytable. This test is obtained with the following code: epi.2by2 (dat = daty, method = "case.control" conf.level = 0.95, units = 100, homogeneity = "breslow.day", verbose = TRUE) where "daty" is the object type table svytable consider it, but