-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding frequentist numerical tests + Integrate StatsAPI #67
Adding frequentist numerical tests + Integrate StatsAPI #67
Conversation
@sourish-cmi
|
|
@@ -221,7 +221,7 @@ function predict(container::FrequentistRegression{:LogisticRegression}, newdata: | |||
return Probit_Link.(z) | |||
elseif (container.link == GLM.CauchitLink) | |||
return Cauchit_Link.(z) | |||
elseif (container.link == GLM.Cloglog) | |||
elseif (container.link == GLM.CloglogLink) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a change to src/frequentist/getter.jl - I think it should be CloglogLink instead of Cloglog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay -- great. thanks.
I added predict and some formulae. For Logistic, Negative binomial and Poisson should there be an example with log on the left? |
No @ShouvikGhosh2048 for Logistic, Negative binomial and Poisson, we don't need a log on the left. |
Perhaps we should check for AIC and BIC > attach(mtcars)
> fit = lm(mpg ~ hp + wt + gear,mtcars)
> AIC(fit)
[1] 157.0528
> BIC(fit)
[1] 164.3815 Add it in the code and check if |
using RDatasets, GLM, StatsBase
mtcars = dataset("datasets", "mtcars")
glm_model = lm(@formula(MPG ~ HP + HP^2 + WT + WT * HP), mtcars)
print(aic(glm_model)) gives 145.92297178935536 and attach(mtcars)
fit = lm(mpg ~ hp + hp^2 + wt + wt * hp, mtcars)
AIC(fit) gives 145.6109. |
In your R-code, there is a syntax mistake.
The correct formula would be as follows: > fit = lm(mpg ~ hp + I(hp^2) + wt + wt * hp, mtcars)
> AIC(fit)
[1] 145.923 |
library("Zelig")
data(turnout)
fit = glm(vote ~ age + I(age^2) + race + income * educate, family = binomial(link = "cloglog"), data = turnout)
sprintf("%.15f", AIC(fit)) gives 2022.884413390652753, using GLM, RDatasets
turnout = dataset("Zelig", "turnout")
model = glm(@formula(Vote ~ Age + Age^2 + Race + Income * Educate), turnout, Binomial(), CloglogLink())
GLM.aic(model) gives 2022.8844886368. library("Zelig")
library(MASS)
data(sanction)
fit = glm.nb(num ~ target + coop + ncost, data = sanction)
sprintf("%.15f", AIC(fit)) gives 344.879549011806205, using GLM, RDatasets
sanction = dataset("Zelig", "sanction")
model = glm(@formula(Num ~ Target + Coop + NCost), sanction, NegativeBinomial(), LogLink())
GLM.aic(model) gives 365.8580428654269. |
Okay, it is an issue with |
@mousum-github can you please check this? |
|
|
|
library(Zelig)
library(MASS)
data(sanction)
fit = glm(num ~ target + coop + ncost, family = negative.binomial(theta=1), data = sanction)
sprintf("%.15f", AIC(fit)) gives 363.858042084877013, which is closer to Julia's value, but still significantly different.
|
@ShouvikGhosh2048 for now, we can remove this example with In this issue can you mention the completeness of the tests? or the cases that I have not considered yet !! |
|
@ShouvikGhosh2048 @mousum-github As discussed in yesterday's meeting we will focus on functional testing.
|
@ShouvikGhosh2048 Mousum da added the negative binomial test, and I approved and merged the test. Perhaps you |
@ShouvikGhosh2048 since you created separate PR for Bayesian tests. I believe now we can merge this PR. Please confirm. |
I've updated the numerical tests for negative binomial. I haven't matched the AIC/BIC values with R - I'm not sure which values to pass to R's negbin to match Julia's negbin. I tried: library(aod)
library(Zelig)
data(sanction)
fit = negbin(num ~ 0 + target + coop + ncost, ~1, sanction)
AIC(fit) This gives 344.896 compared to CRRao's 344.87955007518536. |
@ShouvikGhosh2048 |
I think it is okay - we can ignore it - it might be those denominator issues of AIC. For time being we can ignore it. I think we should go ahead and merge it. Please do let me know your thought. |
We can merge it for now (to make sure our frequentist models are consistent), but we should keep track of this. |
I have filed the issue with the title AIC value for negbin regression does not matches with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All codes are checked and passed. Closing the PR - while opening a new issue
This PR adds frequentist numerical tests, and also integrates StatsAPI into CRRao.