R Users I am a new user of R. I have sample weights that I would like to apply to some of the variables in my data set. Where can I go for information on how to do that? Richard
Dear Richard, See the survey package. John At 11:07 AM 3/22/2003 -0800, Reed, Richard W wrote:> I am a new user of R. I have sample weights that I would like to >apply to some of the variables in my data set. Where can I go for >information on how to do that?----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox -----------------------------------------------------
Hi John-- I haven't seen anything on the website that has a name like that. Do you mean "The R Environment for Statistical Computing and Graphics: Reference Manual"? Richard -----Original Message----- From: John Fox [mailto:jfox at mcmaster.ca] Sent: Saturday, March 22, 2003 12:15 PM To: Reed, Richard W Cc: 'r-help at lists.R-project.org' Subject: Re: [R] Sample weights Dear Richard, See the survey package. John At 11:07 AM 3/22/2003 -0800, Reed, Richard W wrote:> I am a new user of R. I have sample weights that I would like to >apply to some of the variables in my data set. Where can I go for >information on how to do that?----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox -----------------------------------------------------
Okay.Thanks, Tony. -----Original Message----- From: rossini at blindglobe.net [mailto:rossini at blindglobe.net] Sent: Saturday, March 22, 2003 1:52 PM To: Reed, Richard W Cc: 'r-help at lists.R-project.org' Subject: Re: [R] Sample weights No, John means that you need to install the survey package from CRAN, which contains analytics for handling sample weights within the context of various inferential tools. There is some documentation that comes with it. best, -tony "Reed, Richard W" <Richard.Reed at med.va.gov> writes:> Hi John-- > I haven't seen anything on the website that has a name like that. Do > you mean "The R Environment for Statistical Computing and Graphics: > Reference Manual"?> Richard > > -----Original Message----- > From: John Fox [mailto:jfox at mcmaster.ca] > Sent: Saturday, March 22, 2003 12:15 PM > To: Reed, Richard W > Cc: 'r-help at lists.R-project.org' > Subject: Re: [R] Sample weights > > > Dear Richard, > > See the survey package. > > John > > At 11:07 AM 3/22/2003 -0800, Reed, Richard W wrote: >> I am a new user of R. I have sample weights that I would like to >>apply to some of the variables in my data set. Where can I go for >>information on how to do that? > > ----------------------------------------------------- > John Fox > Department of Sociology > McMaster University > Hamilton, Ontario, Canada L8S 4M4 > email: jfox at mcmaster.ca > phone: 905-525-9140x23604 > web: www.socsci.mcmaster.ca/jfox > ----------------------------------------------------- > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini at u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini at scharp.org -------------- http://software.biostat.washington.edu/ -------------------- FHCRC:Tu: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX (CHANGE: monday/wednesday/friday locations are completely unpredictable.) ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Dear R Users-- I am trying to apply a sample weight variable to my calculations. The dataset is from the Department of Labor. I believe that NORC constructed the sample and did the sampling. They sampled nearly 17,000 young adults. The sample weight variable converts the sample into the 34,000,000 in the US population that they represent. I imported AFQT from SPSS. When I query, "is.data.frame(AFQT)" the answer is TRUE. I am trying to apply svydesign from the Survey Package: svydesign(ids, probs=NULL, strata = NULL, variables = NULL, fpc=NULL, data NULL, nest = FALSE, check.strata = !nest, weights=NULL) Below represents my effort to apply the function and the error message (which I don''t understand).> AFQTs<-svydesign(id=~0,weights=AFQT$ASVABSW,data=AFQT)Error in apply(probs, 1, prod) : dim(X) must have a positive length Thanks for your help-- Richard
On Sun, 30 Mar 2003, Reed, Richard W wrote:> Dear R Users-- > > I am trying to apply a sample weight variable to my calculations. > The dataset is from the Department of Labor. I believe that NORC constructed > the sample and did the sampling. They sampled nearly 17,000 young adults. > The sample weight variable converts the sample into the 34,000,000 in the US > population that they represent. I imported AFQT from SPSS. When I query, > "is.data.frame(AFQT)" the answer is TRUE. > > I am trying to apply svydesign from the Survey Package: > > svydesign(ids, probs=NULL, strata = NULL, variables = NULL, fpc=NULL, data > NULL, nest = FALSE, check.strata = !nest, weights=NULL) > > Below represents my effort to apply the function and the error message > (which I don''t understand). > > AFQTs<-svydesign(id=~0,weights=AFQT$ASVABSW,data=AFQT) > Error in apply(probs, 1, prod) : dim(X) must have a positive lengthIt''s a bug. It seems that weights must be a formula or dataframe, vectors aren''t allowed. That is, you want AFQTs<-svydesign(id=~0, weights=~ASVABSW, data=AFQT) This formulation works on the `fpc'' example in the package data(fpc) svydesign(id=~0, weights=~weight, data=fpc) You can also do svydesign(id=~0,weights=data.frame(AFQT$ASVABSW), data=AFQT) In this case you wouldn''t want to, but if the weight vector wasn''t a componet of the data frame it might be necessary Thanks for pointing this out. -thomas