zelig_qi_to_df: Extract simulated quantities of interest from a zelig object

Description Usage Arguments Details Author(s) Source See Also Examples

View source: R/interface.R

Description

Extract simulated quantities of interest from a zelig object

Usage

1

Arguments

obj

a zelig object with simulated quantities of interest

Details

A simulated quantities of interest in a tidy data formatted data.frame. This can be useful for creating custom plots.

Each row contains a simulated value and each column contains:

For multinomial reponse models, a separate column is given for the expected probability of each outcome in the form expected_*. Additionally, there a is column of the predicted outcomes (predicted_value).

Author(s)

Christopher Gandrud

Source

For a discussion of tidy data see https://www.jstatsoft.org/article/view/v059i10.

See Also

qi_slimmer

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
40
41
42
43
44
45
46
#### 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)
z.1 <- sim(z.1)
head(zelig_qi_to_df(z.1))

#### QIs for first differences
z.2 <- zelig(Petal.Width ~ Petal.Length + Species, data = iris,
             model = "ls")
z.2a <- setx(z.2, Petal.Length = 2)
z.2b <- setx(z.2, Petal.Length = 4.4)
z.2 <- sim(z.2, x = z.2a, x1 = z.2a)
head(zelig_qi_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.3a <- setx(z.3, Petal.Length = 2)
z.3b <- setx(z.3, Petal.Length = 4.4)
z.3 <- sim(z.3, x = z.3a, x1 = z.3a)
head(zelig_qi_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)
z.4 <- sim(z.4)
head(zelig_qi_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)
z.5 <- sim(z.5)
head(zelig_qi_to_df(z.5))

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

head(zelig_qi_to_df(z.6))

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