IQSS / Zelig

A statistical framework that serves as a common interface to a large range of models

Home Page:http://zeligproject.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_predict()

VahidTehrani opened this issue · comments

It looks something is not right in the get_predict() function.

data(mid)
z.out1 <- zelig(conflict ~ major + contig + power + maxdem + mindem + years,
                data = mid, model = "relogit", tau = 1042/303772)
prob <- z.out1$get_predict()
max(sapply(prob, max))
min(sapply(prob, min))

and return 0.9610796 as max and -10.59513 as min. Does it make sense? It supposed to be probability!! The link fucntion is 'logit'.

Thanks for reporting @VahidTehrani. I'll take a look.

I think it's because currently the type argument to predict is not set as response. Not great use-ability for this case, so I'll work on a better solution.

In the mean time:

library(zeligverse)
data(mid)
z.out1 <- zelig(conflict ~ major + contig + power + maxdem + mindem + years,
                data = mid, model = "relogit", tau = 1042/303772)

# Extract fitted model object and predict response probabilities
fitted_model <- from_zelig_model(z.out1)
prob <- predict(fitted_model, type = "response")

max(sapply(prob, max))
min(sapply(prob, min))

From 971809e predict accepts arguments (like type = "response")