WSrg: Weighted sums by rotation groups

Description Usage Arguments Value Examples

View source: R/WSrg.R

Description

Weighted sums by rotation groups

Usage

1
2
3
4
5
6
7
8
WSrg(
  list.tables,
  weight = 1,
  list.y = NULL,
  rg = "hrmis",
  rescale = F,
  dimname1 = "m"
)

Arguments

list.tables

a named list of data frames

weight

a character string indicating the variable name or a numerical value

list.y

a vector of character strings indicating the study variables

rg

a character string indicating the name of the rotation group.

Value

an array

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(dataCPS)
period<-200501:200512
list.tables<-lapply(data(list=paste0("cps",period),package="dataCPS"),get);
names(list.tables)<-period
Y<-WSrg(list.tables,"pwsswgt",list.y="pemlr",rg="hrmis")
dimnames(Y);dim(Y)
Y<-plyr::daply(plyr::ldply(list.tables,function(L){L[c("pemlr","pwsswgt","hrmis")]},.id="m"),
~m+pemlr+hrmis,function(d){data.frame(y=sum(d$pwsswgt))})[names(list.tables),,]
dimnames(Y);dim(Y)
system.time(plyr::daply(plyr::ldply(list.tables,,function(L){L[c("pemlr","pwsswgt","hrmis")]}),
~.id+pemlr+hrmis,function(d){data.frame(y=sum(d$pwsswgt))}))
system.time(WSrg(list.tables,weight="pwsswgt",list.y="pemlr",rg="hrmis"))

DanielBonnery/CompositeRegressionEstimation documentation built on June 17, 2020, 12:16 p.m.