ararslan / betaregression.jl Goto Github PK
View Code? Open in Web Editor NEWRegression models for beta distributed responses in Julia
License: MIT License
Regression models for beta distributed responses in Julia
License: MIT License
Convergence can fail for models of the form y ~ 1
when y
is a random sample from one of the following beta distributions. In each case, the cause of convergence failure has to do with the precision estimate. The particular failure mode regarding the precision is included.
Beta(0.5, 0.5)
: Initial estimate from initialize!
is invalid (EDIT: Fixed by #4)Beta(0.2, 0.2)
: Estimate becomes negative during fittingBeta(0.5, 10)
: Estimate becomes negative during fittingBeta(10, 0.3)
: Estimate becomes negative during fittingFor invalid initialization of the precision, we can follow suit with the R package betareg
and set the starting value to 1 (see #4). Doing so allows this model to be fit, and the estimates obtained match those obtained from betareg
.
The negative precision currently causes an issue in weightdiag
due to what seemed like an obvious simplification at the time (but in retrospect is obviously incorrect): the simplification assumes sqrt(ϕ^2) == ϕ
, which is only true if ϕ ≥ 0
. (In my defense, ϕ
is supposed to be positive!) Undoing this simplification causes fitting to throw a ConvergenceException
from fit
rather than a DomainError
from sqrt
.
However, betareg
actually succeeds in fitting these models on the same data. My very scientific means of determining this:
y = rand(Beta(0.2, 0.2), 10)
fit(BetaRegressionModel, ones(10, 1), y)
clipboard(strip(sprint(show, y), ['[', ']']))
betareg(y ~ 1, data.frame(y=c(...)), link="logit", link.phi="identity", type="ML")
where ...
is the contents of my clipboard.
The betareg
documentation notes that fitting is performed using R's optim
with the default method set to BFGS. Fitting in this package is performed by Fisher scoring (i.e. Newton's method). I'm not sure what effect that difference could have in practice but it's worth noting.
Hi there,
Is there an intention to enable the precision parameter to be modelled with predictors?
Cheers
Seems like some nice functionality to share. 😄
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
Some stubs are currently in place but we deliberately throw an error when weights are actually specified. The Ferrari 2004 paper makes no mention of weights and I haven't yet bothered to work out the math myself. Off the top of my head, I think what's needed is to account for it in the linear predictor updates, score vector, and expected Fisher information.
Looking at the R documentation for betareg, it appears they only accept case weights. It would likely be easiest to follow suit and use FrequencyWeights
from StatsBase (and just wrap any plain input vector with that type). That makes testing against output from R easier.
I almost surely won't block an initial package release on having this feature.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.