search for: apiclus1

Displaying 15 results from an estimated 15 matches for "apiclus1".

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" ) ] #the goal is to replace pcttest with 100, api100 with NA, and sch.wide with "Maybe" #this doesn't work-- apiclus1[ apiclus1$meals > 98 , c( "pcttest" , "api00" , &...
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(~ api99, dclus1).) I guess that the problem ha...
2005 Apr 12
1
calling svydesign function that uses model.frame
I need help on calling the svydesign function in the survey package (although this error appears not to be specific to svydesign). I am passing parameters incorrectly but am not sure how to correct the problem. ## Call the main function PS.sim (one of mine). The dots are parameters I omitted to simplify the question. ## y.col, str.col, clus.id, and PS.col are names of columns in the object pop.
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$replicates [1] 606.8488 611.5866 609.1989 605.5765...
2009 Mar 11
1
CI from svyquantile in survey package
...erstanding (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??? and 'data.frame': 3 obs. of 3 variab...
2010 Mar 10
1
Strange result in survey package: svyvar
...e 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<-svyvar(~api00+enroll+api.stu+api99, dclus1) pr...
2012 Sep 21
1
Exactly Replicating Stata's Survey Data Confidence Intervals in R
...hes exactly except for the confidence intervals, and then displays a number of my failed attempts at hitting the numbers right on the nose. Thanks!! Anthony Damico Kaiser Family Foundation * Stata/MP 11.2 * example stata code to replicate in R use http://www.ats.ucla.edu/stat/stata/library/apiclus1, clear svyset dnum [pw=pw], fpc(fpc) gen ell0 = 1 replace ell0 = 0 if ell != 0 svy: mean ell0 * results of the final command above: (running mean on estimation sample) Survey: Mean estimation Number of strata = 1 Number of obs = 183 Number of PSUs = 15 Pop...
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-linux-gnu) and have installed survey_3.4-4.tar.gz u...
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 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 general question is: can quantiles and their SEs be...
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()
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
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 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
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