W.ak: general AK weights as a function of a and k parameters.

Description Usage Arguments Value Examples

View source: R/AK3.R

Description

general AK weights as a function of a and k parameters.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
W.ak(
  months,
  groups = 1:8,
  S = c(2:4, 6:8),
  S_1 = S - 1,
  a,
  k,
  eta0 = length(groups)/length(S),
  eta1 = eta0 - 1,
  rescaled = F
)

Arguments

months

an integer, indicating number of months

groups

a vector of character strings or numeric string

S

a vector of integers indicating the indices of the rotation group in the sample that overlap with the previous sample: groups[S] are the overlapping rotation groups

S_1

a vector of integers indicating the indices of the corresponding rotation group of S in the previous month

a

a numeric value

k

a numeric value

rescaled

a boolean (default FALSE) indicating whether these AK coefficient are to be applied to rescaled or not rescaled month in sample weighted sums

nmonth

an integer, indicating number of months

ngroup

a vector of character strings or numeric string

Value

an array of AK coefficients W[m2,m1,mis1] such that Ak estimate for month m2 is sum(W[y2,,])*Y) where Y[m1,mis1] is direct estimate on mis mis1 for emp stat y1 at month m1.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
library(dataCPS)
period=200501:200512
list.tables<-lapply(data(list=paste0("cps",period),package="dataCPS"),get);
W<-W.ak(months=1:3,groups=1:8,a=.2,k=.5);dimnames(W) 
W<-W.ak(months=2:4,groups=letters[1:8],a=.2,k=.5);dimnames(W);
Y<-WSrg(list.tables,weight="pwsswgt",list.y="pemlr",rg="hrmis")
dimnames(Y);month="m";group="hrmis";variable="y";
months = dimnames(Y)[[month]]
W<-W.ak(months = months,
     groups = dimnames(Y)[[group]],
     S=c(2:4,6:8),
     a=.5,k=.3)
a=.5;k=.3
dimnames(W)
W[1,1,]  #should be all 1s   
m<-sample(2:length(months),1)
if(all(abs(W[m,m,c(1,5)]-(1-k+a))<1e-10)){"this part is fine"}else{"there is a problem"}    
if(all(abs(W[m,m,c(2:4,6:8)]-(1-k+4*k/3-a/3))<1e-10)){"this part is fine"}else{"there is a problem"}    
if(all(abs(W[m,m-1,c(1:3,5:7)]-(k*W[m-1,m-1,c(1:3,5:7)]-4*k/3))<1e-10)){"this part is fine"}else{"there is a problem"}    
if(all(abs(W[m-1,m,c(1:3,5:7)]-(k*W[m-1,m-1,c(1:3,5:7)+1]-4*k/3))<1e-10)){"this part is fine"}else{"there is a problem"}    
W[2,1,]     
W[2,2,c(1,5)];((1-k)+a)  #Should be equal     

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