Checks whether Calibration Constraints are fulfilled; if not, assesses constraints violation degree.

check.cal(cal.design)

Arguments

cal.design

Object of class cal.analytic.

Details

The function verifies if all the imposed Calibration Constraints are actually fulfilled by object cal.design. If it is not the case, the function evaluates the degree of violation of the constraints and prints a summary of the mismatches between population totals and achieved estimates (see also Section 'Calibration process diagnostics' in the help page of e.calibrate).

Value

The main purpose of the function is to print on screen; anyway a list is invisibly returned, which summarizes the results of the check.

See also

e.calibrate for calibrating weights (in particular, Section 'Calibration process diagnostics').

Examples

# Load sbs data: data(sbs) # Build a design object: sbsdes<-e.svydesign(data=sbs,ids=~id,strata=~strata,weights=~weight,fpc=~fpc) ## Example 1 # Build template... pop<-pop.template(sbsdes,~emp.num:emp.cl+ent-1,~region) # Fill template... pop<-fill.template(sbs.frame,pop)
#> #> # Coherence check between 'universe' and 'template': OK #>
# Calibrate... sbscal<-e.calibrate(sbsdes,pop,sigma2=~emp.num) # Check calibration... check.cal(sbscal)
#> All Calibration Constraints (18) fulfilled (at tolerance level epsilon = 1e-07). #>
## Example 2 # Build template... pop<-pop.template(sbsdes,~emp.num+ent-1,~area) # Fill template... pop<-fill.template(sbs.frame,pop)
#> #> # Coherence check between 'universe' and 'template': OK #>
# Calibrate with tight bounds... sbscal<-e.calibrate(sbsdes,pop,sigma2=~emp.num,bounds=c(0.8,1.2))
#> Warning: Failed to converge: worst achieved epsilon= 0.0194513367018903 in 51 iterations (variable emp.num), see ecal.status.
#> Warning: Failed to converge: worst achieved epsilon= 0.0277324210736077 in 51 iterations (variable ent), see ecal.status.
#> Warning: Failed to converge: worst achieved epsilon= 0.404491630153915 in 51 iterations (variable ent), see ecal.status.
#> Warning: Failed to converge: worst achieved epsilon= 0.0217273815249365 in 51 iterations (variable emp.num), see ecal.status.
#> Warning: Failed to converge: worst achieved epsilon= 0.145748688243651 in 51 iterations (variable emp.num), see ecal.status.
#> Warning: Failed to converge: worst achieved epsilon= 0.116061399717895 in 51 iterations (variable emp.num), see ecal.status.
# Check calibration... check.cal(sbscal)
#> Calibration Constraints missed (at tolerance level epsilon = 1e-07): 12 out of 48 #> - Summary of mismatches: #> #> $return.code #> 11 12 13 14 15 16 17 21 22 23 24 31 32 33 34 41 42 43 51 52 53 61 62 63 #> code 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 0 0 1 #> #> $fail.diagnostics #> $fail.diagnostics$`23` #> Variable Population.Total Achieved.Estimate Difference Relative.Difference #> 1 emp.num 2568 2518.02952 -49.970484 -0.01945134 #> 2 ent 91 92.69386 1.693861 0.01841153 #> #> $fail.diagnostics$`33` #> Variable Population.Total Achieved.Estimate Difference Relative.Difference #> 2 ent 363 373.0946 10.09460 0.027732421 #> 1 emp.num 12698 12660.3480 -37.65195 -0.002964954 #> #> $fail.diagnostics$`42` #> Variable Population.Total Achieved.Estimate Difference Relative.Difference #> 2 ent 128 75.82058 -52.17942 -0.4044916 #> 1 emp.num 3885 3098.78638 -786.21362 -0.2023195 #> #> $fail.diagnostics$`43` #> Variable Population.Total Achieved.Estimate Difference Relative.Difference #> 1 emp.num 3082 3015.0145 -66.9855172 -0.021727382 #> 2 ent 125 124.6897 -0.3103448 -0.002463054 #> #> $fail.diagnostics$`53` #> Variable Population.Total Achieved.Estimate Difference Relative.Difference #> 1 emp.num 970 828.478 -141.521976 -0.14574869 #> 2 ent 47 43.365 -3.634997 -0.07572911 #> #> $fail.diagnostics$`63` #> Variable Population.Total Achieved.Estimate Difference Relative.Difference #> 1 emp.num 1931 1706.76938 -224.230624 -0.1160614 #> 2 ent 73 81.23913 8.239128 0.1113396 #> #> #>
# Now try to calibrate with suggested bounds... hint <- bounds.hint(sbsdes,pop)
#> #> A starting suggestion: try to calibrate with bounds=c(0.071, 2.663) #> #> Remark: this is just a hint, not an exact result #> Feasible bounds for calibration problem must cover the interval [0.719, 2.015] #>
sbscal<-e.calibrate(sbsdes,pop,sigma2=~emp.num,bounds=hint) # Check calibration... check.cal(sbscal)
#> All Calibration Constraints (48) fulfilled (at tolerance level epsilon = 1e-07). #>