IQSS / Zelig

A statistical framework that serves as a common interface to a large range of models
http://zeligproject.org
109 stars 43 forks source link

get_predict() #320

Closed VahidTehrani closed 6 years ago

VahidTehrani commented 6 years ago

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

christophergandrud commented 6 years ago

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

christophergandrud commented 6 years ago

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))
christophergandrud commented 6 years ago

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

VahidTehrani commented 6 years ago

Thanks! @christophergandrud