zelig_setx_to_df: Extracted fitted values from a Zelig object with 'setx'...

Description Usage Arguments Details Author(s) Examples

View source: R/interface.R

Description

Extracted fitted values from a Zelig object with setx values

Usage

1

Arguments

obj

a zelig object with simulated quantities of interest

Details

Fitted (setx) values in a tidy data formatted data.frame. This was designed to enable the WhatIf package's whatif function to extract "counterfactuals".

Author(s)

Christopher Gandrud

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#### QIs without first difference or range, from covariates fitted at
## central tendencies
z.1 <- zelig(Petal.Width ~ Petal.Length + Species, data = iris,
             model = "ls")
z.1 <- setx(z.1)
zelig_setx_to_df(z.1)

#### QIs for first differences
z.2 <- zelig(Petal.Width ~ Petal.Length + Species, data = iris,
             model = "ls")
z.2 <- setx(z.2, Petal.Length = 2)
z.2 <- setx1(z.2, Petal.Length = 4.4)
zelig_setx_to_df(z.2)

#### QIs for first differences, estimated by Species
z.3 <- zelig(Petal.Width ~ Petal.Length, by = "Species", data = iris,
             model = "ls")
z.3 <- setx(z.3, Petal.Length = 2)
z.3 <- setx1(z.3, Petal.Length = 4.4)
zelig_setx_to_df(z.3)

#### QIs for a range of fitted values
z.4 <- zelig(Petal.Width ~ Petal.Length + Species, data = iris,
             model = "ls")
z.4 <- setx(z.4, Petal.Length = 2:4)
zelig_setx_to_df(z.4)

#### QIs for a range of fitted values, estimated by Species
z.5 <- zelig(Petal.Width ~ Petal.Length, by = "Species", data = iris,
             model = "ls")
z.5 <- setx(z.5, Petal.Length = 2:4)
zelig_setx_to_df(z.5)

#### QIs for two ranges of fitted values
z.6 <- zelig(Petal.Width ~ Petal.Length + Species, data = iris,
             model = "ls")
z.6 <- setx(z.6, Petal.Length = 2:4, Species = "setosa")
z.6 <- setx1(z.6, Petal.Length = 2:4, Species = "virginica")
zelig_setx_to_df(z.6)

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