Extract simulated quantities of interest from a zelig object

zelig_qi_to_df(obj)

Arguments

obj

a zelig object with simulated quantities of interest

Source

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

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:

  • setx_value whether the simulations are from the base x setx or the contrasting x1 for finding first differences.

  • The fitted values specified in setx including a by column if by was used in the zelig call.

  • expected_value

  • predicted_value

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).

See also

qi_slimmer

Examples

#### 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))
#> zelig_qi_to_df is an experimental function. #> Please report issues to: https://github.com/IQSS/Zelig/issues
#> setx_value Petal.Length Species expected_value predicted_value #> 1 x 3.758 virginica 1.556644 1.573390 #> 2 x 3.758 virginica 1.608859 1.357268 #> 3 x 3.758 virginica 1.646423 1.589401 #> 4 x 3.758 virginica 1.518272 1.246964 #> 5 x 3.758 virginica 1.519643 1.389558 #> 6 x 3.758 virginica 1.707326 1.478405
#### 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))
#> zelig_qi_to_df is an experimental function. #> Please report issues to: https://github.com/IQSS/Zelig/issues
#> setx_value Petal.Length Species expected_value predicted_value #> 1 x 2 virginica 0.9795631 1.0710712 #> 2 x 2 virginica 1.2058482 1.1224267 #> 3 x 2 virginica 1.2597302 1.6488994 #> 4 x 2 virginica 1.1584787 1.0987905 #> 5 x 2 virginica 0.9592988 0.9034156 #> 6 x 2 virginica 1.0460941 0.9169915
#### 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))
#> zelig_qi_to_df is an experimental function. #> Please report issues to: https://github.com/IQSS/Zelig/issues
#> setx_value by Petal.Length expected_value predicted_value #> 1 x setosa 2 0.4200569 0.20333867 #> 2 x setosa 2 0.3072372 0.02505914 #> 3 x setosa 2 0.4237643 0.44112644 #> 4 x setosa 2 0.3003825 0.49131407 #> 5 x setosa 2 0.3697732 0.55603910 #> 6 x setosa 2 0.3170738 0.34239949
#### 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))
#> zelig_qi_to_df is an experimental function. #> Please report issues to: https://github.com/IQSS/Zelig/issues
#> setx_value Petal.Length Species expected_value predicted_value #> 1 x 2 virginica 1.294700 1.3123182 #> 2 x 2 virginica 1.099721 1.1634645 #> 3 x 2 virginica 1.181263 1.3535331 #> 4 x 2 virginica 1.070903 0.9460419 #> 5 x 2 virginica 1.373463 1.3802044 #> 6 x 2 virginica 1.177438 1.2947376
#### 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))
#> zelig_qi_to_df is an experimental function. #> Please report issues to: https://github.com/IQSS/Zelig/issues
#> setx_value by Petal.Length expected_value predicted_value #> 1 x setosa 2 0.3646708 0.2891910 #> 2 x setosa 2 0.3090093 0.5100030 #> 3 x setosa 2 0.3037640 0.1264876 #> 4 x setosa 2 0.3812836 0.4066486 #> 5 x setosa 2 0.3499157 0.3849238 #> 6 x setosa 2 0.3865099 0.3164888
#### 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_qi_to_df is an experimental function. #> Please report issues to: https://github.com/IQSS/Zelig/issues
#> setx_value Petal.Length Species expected_value predicted_value #> 1 x 2 setosa 0.3422110 0.6173951 #> 2 x 2 setosa 0.3537809 0.3583462 #> 3 x 2 setosa 0.4216868 0.3571729 #> 4 x 2 setosa 0.3672208 0.5044029 #> 5 x 2 setosa 0.4070478 0.1279746 #> 6 x 2 setosa 0.3711670 0.6798636