Description Usage Arguments Details Value See Also Examples
View source: R/PanelEstimation.R
Variance estimation of linear combinations of totals and ratios based on output from wideFromCalibrate
1 2 3 4 5 6 7 8 9 10 11 12 |
x |
Output from wideFromCalibrate. |
numerator |
y variable name or number. |
denominator |
y variable name or number. |
linComb |
Matrix defining linear combinations of waves. |
linComb0 |
Linear combination matrix to be used prior to ratio calculations. |
estType |
Estimation type: "robustModel" (default), "ssbAKU", "robustModelww", "robustModelGroup" or "robustModelGroupww" (see below) |
leveragePower |
Power used when adjusting residuals using leverages. |
group |
Extra variable name or number for cluster robust estimation. |
returnCov |
Return covariance matrices instead of variance vectors. |
usewGross |
Use wGross (if avaliable) instead of design weights to adjust covariance matrix in the case of NA popTotals |
When denominator=NULL, only estimates for a single y-variable (numerator) are calculated. When denominator is specified, estimates for numerator, denominator and ratio are calculated. The default estimation type parameter, "robustModel", is equation (12) in paper. "ssbAKU" is (16), "robustModelww" is (9) and "robustModelGroup" and "robustModelGroupww" are cluster robust variants based on (w-1)^2 and w^2 .
wTot |
Sum of weights |
estimates |
Ordinary estimates |
linCombs |
Estimates of linear combinations |
varEstimates |
Variance of estimates |
varLinCombs |
Variance of estimates of linear combinations |
When denominator is specified the above output refer to ratios. Then, similar output for numerator and denominator are also included.
CalibrateSSB
, CalSSBobj
, WideFromCalibrate
, CalibrateSSBpanel
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # Generates data - two years
z = AkuData(3000) # 3000 in each quarter
zPop = AkuData(10000)[,1:7]
# Calibration and "WideFromCalibrate"
b = CalibrateSSB(z,calmodel="~ sex*age", partition=c("year","q"),
popData=zPop, y=c("unemployed","workforce"))
bWide = WideFromCalibrate(b,CrossStrata(z[,c("year","q")]),z$id)
# Define linear combination matrix
lc = rbind(LagDiff(8,4),PeriodDiff(8,4))
rownames(lc) = c("diffQ1","diffQ2","diffQ3","diffQ4","diffYearMean")
colnames(lc) = colnames(head(bWide$y[[1]]))
lc
# Unemployed: Totals and linear combinations
d1=PanelEstimation(bWide,"unemployed",linComb=lc) #
# Table of output
cbind(tot=d1$estimates,se=sqrt(d1$varEstimates))
cbind(tot=d1$linCombs,se=sqrt(d1$varLinCombs))
# Ratio: Totals and linear combinations
d=PanelEstimation(bWide,numerator="unemployed",denominator="workforce",linComb=lc)
cbind(tot=d$estimates,se=sqrt(d$varEstimates))
cbind(tot=d$linCombs,se=sqrt(d$varLinCombs))
## Not run:
# Calibration when som population totals unknown (edu)
# Leverages in output (will be used to adjust residuals)
# Cluster robust estimation (families/famid)
b2 = CalibrateSSB(z,popData=zPop,calmodel="~ edu*sex + sex*age",
partition=c("year","q"), y=c("unemployed","workforce"),
leverageOutput=TRUE)
b2Wide = WideFromCalibrate(b2,CrossStrata(z[,c("year","q")]),z$id,extra=z$famid)
d2 = PanelEstimation(b2Wide,"unemployed",linComb=lc,group=1,estType = "robustModelGroup")
cbind(tot=d2$linCombs,se=sqrt(d2$varLinCombs))
## End(Not run)
# Yearly mean before ratio calculation (linComb0)
# and difference between years (linComb)
g=PanelEstimation(bWide,numerator="unemployed",denominator="workforce",
linComb= LagDiff(2),linComb0=Period(8,4))
cbind(tot=g$linCombs,se=sqrt(g$varLinCombs))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.