Skip to contents

A svyplan_overlap from design_overlap() is a numeric vector of overlap fractions indexed by lag, so x[1] and x[12] are plain numbers ready for an overlap argument. $ reaches the counts and the rotation behind them.

Usage

# S3 method for class 'svyplan_overlap'
print(x, ...)

# S3 method for class 'svyplan_overlap'
format(x, ...)

# S3 method for class 'svyplan_overlap'
as.double(x, ...)

# S3 method for class 'svyplan_overlap'
as.list(x, ...)

# S3 method for class 'svyplan_overlap'
x[i]

# S3 method for class 'svyplan_overlap'
Ops(e1, e2)

# S3 method for class 'svyplan_overlap'
Math(x, ...)

# S3 method for class 'svyplan_overlap'
x[[i]]

# S3 method for class 'svyplan_overlap'
x$name

# S3 method for class 'svyplan_overlap'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  stringsAsFactors = FALSE,
  validRN = TRUE,
  ...
)

# S3 method for class 'svyplan_overlap'
x[i] <- value

# S3 method for class 'svyplan_overlap'
x[[i]] <- value

Arguments

x

A svyplan_overlap object.

...

Additional arguments are not supported and produce an error.

i

Lag to extract, by position or by its name, so x[12] and x[["12"]] are both the twelve-occasion overlap. The result is a bare number, carrying neither the class nor the lag as a name.

e1, e2

Operands. Arithmetic and comparison return bare numerics, the counts and the rotation describing the profile as computed and not whatever it was transformed into.

name

Field to extract: overlap, shared, n_occasion, rotation, lag or life.

row.names, optional, stringsAsFactors, validRN

Standard as.data.frame() arguments.

value

Replacement value. Replacement is refused, an overlap being computed from a rotation rather than assembled.

Value

The method-specific result:

print()

Returns x invisibly.

format()

Returns a string.

as.double()

Returns the overlap vector.

as.data.frame()

Returns one row per lag.

Ops() and Math()

Return bare numerics.

Replacement is an error.

Details

The values, the shared counts and the rotation describe one design, so nothing may move the values while leaving the rest: subsetting and arithmetic return bare numerics, and replacement is an error. That also settles pmax() and pmin(), which copy the attributes of their first argument without dispatching to any method and would otherwise return something still labelled an overlap whose counts no longer follow from its values. They assign through [<-, so they are refused here too. Convert with as.double(x) and they work as usual.

See also

design_overlap(), which builds these objects, design_rotation() for the pattern behind them, plot.svyplan_overlap() for the rotation chart, and print.svyplan_schedule() for the operational schedule a rotation becomes.

Examples

cps <- design_overlap("4-8-4")
cps
#> Rotation overlap (planning)
#> 
#>   16-occasion life, 8 in sample each occasion
#>   rotation: 4 in, 8 out, 4 in
#> 
#>  lag shared overlap
#>   1  6      0.75   
#>   2  4      0.5    
#>   3  2      0.25   
#>   4  0      0      
#>   5  0      0      
#>   6  0      0      
#>   7  0      0      
#>   8  0      0      
#>   9  1      0.125  
#>  10  2      0.25   
#>  11  3      0.375  
#>  12  4      0.5    
#>  13  3      0.375  
#>  14  2      0.25   
#>  15  1      0.125  

# one lag, as a bare number, which is what the overlap arguments take
cps[1]
#> [1] 0.75
cps[["12"]]
#> [1] 0.5

# the fields behind the values
cps$shared
#>  [1] 6 4 2 0 0 0 0 0 1 2 3 4 3 2 1
cps$rotation
#> Rotation pattern (planning)
#> 
#>   16-occasion life, 8 in sample each occasion
#>   rotation: 4 in, 8 out, 4 in
as.data.frame(cps)
#>    lag shared n_occasion overlap
#> 1    1      6          8   0.750
#> 2    2      4          8   0.500
#> 3    3      2          8   0.250
#> 4    4      0          8   0.000
#> 5    5      0          8   0.000
#> 6    6      0          8   0.000
#> 7    7      0          8   0.000
#> 8    8      0          8   0.000
#> 9    9      1          8   0.125
#> 10  10      2          8   0.250
#> 11  11      3          8   0.375
#> 12  12      4          8   0.500
#> 13  13      3          8   0.375
#> 14  14      2          8   0.250
#> 15  15      1          8   0.125

# arithmetic drops the class rather than carrying stale counts
as.double(cps)[1:3]
#> [1] 0.75 0.50 0.25