Learn R Programming

ergm.ego (version 1.1.0)

*.svystat: A scalar multiplication method for svystat

Description

Multiply the values of survey statistics by a specified vector elementwise, adjusting the variance.

Usage

# S3 method for svystat
*(x, y)

Value

a [svystat][survey::svymean] object with the updated statistics and variance-covariance matrix.

Arguments

x

an object of class [svystat][survey::svymean].

y

a numeric vector equal in length to x; shorter vectors will be recycled.

Examples

Run this code
library(survey)
data(api)
# From example(svymean):
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)

(m1 <- svymean(~api99, dclus1))
(v1 <- vcov(m1))

# Scale the suvery stat object by a factor of two:
(m2 <- m1 * 2)
(v2 <- vcov(m2))

# \dontshow{
stopifnot(isTRUE(all.equal(as.vector(m2), as.vector(m1)*2, check.attributes=FALSE)))
stopifnot(isTRUE(all.equal(v2, v1*4)))
# }

Run the code above in your browser using DataLab