setx1: Setting Explanatory Variable Values for First Differences

Description Usage Arguments Value Author(s) See Also Examples

View source: R/wrappers.R

Description

This documentation describes the setx1 Zelig 4 compatibility wrapper function. The wrapper is primarily useful for setting fitted values for creating first differences in piped workflows.

Usage

1
setx1(obj, fn = NULL, data = NULL, cond = FALSE, ...)

Arguments

obj

output object from zelig

fn

a list of functions to apply to the data frame

data

a new data frame used to set the values of explanatory variables. If data = NULL (the default), the data frame called in zelig is used

cond

a logical value indicating whether unconditional (default) or conditional (choose cond = TRUE) prediction should be performed. If you choose cond = TRUE, setx1 will coerce fn = NULL and ignore the additional arguments in .... If cond = TRUE and data = NULL, setx1 will prompt you for a data frame.

...

user-defined values of specific variables for overwriting the default values set by the function fn. For example, adding var1 = mean(data\$var1) or x1 = 12 explicitly sets the value of x1 to 12. In addition, you may specify one explanatory variable as a range of values, creating one observation for every unique value in the range of values

Value

The output is returned in a field to the Zelig object. For unconditional prediction, x.out is a model matrix based on the specified values for the explanatory variables. For multiple analyses (i.e., when choosing the by option in zelig, setx1 returns the selected values calculated over the entire data frame. If you wish to calculate values over just one subset of the data frame, the 5th subset for example, you may use: x.out <- setx(z.out[[5]])

Author(s)

Christopher Gandrud, Matt Owen, Olivia Lau, Kosuke Imai

See Also

The full Zelig manual may be accessed online at http://docs.zeligproject.org/articles/

Examples

1
2
3
4
5
6
7
8
9
library(dplyr) # contains pipe operator %>%
data(turnout)

# plot first differences
zelig(Fertility ~ Education, data = swiss, model = 'ls') %>%
      setx(z4, Education = 10) %>%
      setx1(z4, Education = 30) %>%
      sim() %>%
      plot()

Zelig documentation built on Jan. 8, 2021, 2:26 a.m.