as.weightit: Create a 'weightit' object manually

View source: R/as.weightit.R

as.weightitR Documentation

Create a weightit object manually

Description

This function allows users to get the benefits of a weightit object when using weights not estimated with \funweightit or \funweightitMSM. These benefits include diagnostics, plots, and direct compatibility with cobalt for assessing balance.

Usage

as.weightit(...)

## Default S3 method:
as.weightit(weights,
            treat,
            covs = NULL,
            estimand = NULL,
            s.weights = NULL,
            ps = NULL,
            ...)

as.weightitMSM(...)

## Default S3 method:
as.weightitMSM(weights,
               treat.list,
               covs.list = NULL,
               estimand = NULL,
               s.weights = NULL,
               ps.list = NULL,
               ...)

Arguments

weights

required; a numeric vector of weights, one for each unit.

treat

required; a vector of treatment statuses, one for each unit.

covs

an optional data.frame of covariates. For using WeightIt functions, this is not necessary, but for use with cobalt it is.

estimand

an optional character of length 1 giving the estimand. The text is not checked.

s.weights

an optional numeric vector of sampling weights, one for each unit.

ps

an optional numeric vector of propensity scores, one for each unit.

treat.list

a list of treatment statuses at each time point.

covs.list

an optional list of data.frames of covariates of covariates at each time point. For using WeightIt functions, this is not necessary, but for use with cobalt it is.

ps.list

an optional list of numeric vectors of propensity scores at each time point.

...

additional arguments. These must be named. They will be included in the output object.

Value

An object of class weightit (for as.weightit()) or weightitMSM (for as.weightitMSM()).

Author(s)

Noah Greifer

Examples

treat <- rbinom(500, 1, .3)
weights <- rchisq(500, df = 2)
W <- as.weightit(weights= weights, treat = treat,
                 estimand = "ATE")
summary(W)

WeightIt documentation built on May 31, 2023, 9:25 p.m.