mle | flexible terminal-based text editor | Editor library
kandi X-RAY | mle Summary
kandi X-RAY | mle Summary
mle is a small, flexible, terminal-based text editor written in C. Runs on Linux, Windows (cygwin or WSL), FreeBSD, and macOS.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mle
mle Key Features
mle Examples and Code Snippets
Community Discussions
Trending Discussions on mle
QUESTION
For return data I am doing research about the importance of skewness and kurtosis for the cVaR calculation. We are comparing some distributions first, by estimating the parameters of the distribution using fitdist() in R using package "fitdistrplus". However, we want to do this for a various number of distributions (see picture: SGT, GT, SGED, GED, t, norm).
Below is a sample code for SGT, where there is a problem: it introduced NaN's for the standard errors for parameters p and q. I also don't really know how to choose the starting values exactly.
...ANSWER
Answered 2021-May-16 at 16:12The answer was using package sgt
QUESTION
I am using the maximum likelihood method to estimate a set of parameters. Now I am going to use mle
function from the stats4
package in R to make a profile likelihood for one of the parameters. To do that, I need to fix one of the parameters when I call the mle
function. Here is the code:
ANSWER
Answered 2021-May-07 at 22:25tl;dr I'm not sure your objective function makes sense, my guess is that you have a typo. (Furthermore, if your objective function is working with mle
, you don't need to set fixed
explicitly: the profile
method will automatically compute likelihood profiles for you ...)
Let's start with the full model, and let's use optim()
rather than stats4::mle()
(I know you want to get back to mle
so that you can do likelihood profiling, but it's a little bit easier to debug optim()
problems since there is one less layer of code to dig through.)
Since optim()
wants an objective function that takes a vector rather than a list of arguments, write a wrapper (we could also use do.call(fr, as.list(p))
):
QUESTION
The log-likelihood returned by the lm
method for the logLik
function does not seem to match that calculated by hand.
To demonstrate, below I fit a standard linear model with only an intercept to a simple dataset with three points. I then extract the log-likelihood using logLik
and calculate it manually by summing the logs of the pdfs evaluated at the mle.
ANSWER
Answered 2021-Apr-28 at 11:14logLik
evaluates the log-likelihood at the maximum-likelihood estimates of the parameters. The maximum-likelihood estimates of the coefficients are the same as the least-squares estimates, but the denominator of the maximum-likelihood estimate of the variance is n
, while summary(mod_lm)$sigma
is the squared-root of the unbiased estimate of the variance, whose denominator is the degrees of freedom, here n-1
. So you get the same results if you do:
QUESTION
I am trying to run an exponential random graph model (ergm) on a weighted network (network_ex). This network shows the interactions between individuals in four different groups. Interactions between groups cannot occur so a blockdiagonal constraint needs to be included in the model. However when I include the blockdiagonal constraint the ergm function (that runs otherwise) returns an error (see below) and my R session either runs indefinitely or abort directly.
Is there a way to run an ergm based on a weighted block diagonal matrix?
...ANSWER
Answered 2021-Mar-24 at 02:10That does appear to be a bug. I've fixed it in the latest development version. These can be obtained by going to https://github.com/statnet/ergm and https://github.com/statnet/ergm.count and either using install_github() or downloading the binaries found in the README. Note, also that, the blockdiag() constraint has been provisionally moved to https://github.com/statnet/tergm .
QUESTION
I am quite new in R and I am stack in getting a table of output values from multiple MLE running for different sample sizes. Here is my code:
...ANSWER
Answered 2021-Mar-03 at 09:46How about using a list of data.frames and then rbindlist
them (a data.table
function)
QUESTION
I would like to find the MLE for parameters epsilon
and mu
in such a model:
$$X \sim \frac{1}{mu1}e^{-x/mu1}+\frac{1}{mu2}e^[-x/mu2}$$
...ANSWER
Answered 2021-Jan-27 at 23:43There are a bunch of issues here. The primary one is that your likelihood expression is wrong (you can't log the components separately and then add them, you have to add the components and then take the log). Your bounds are also funny: the mixture probability should be [0,1] and the means should be [0, Inf].
The other problem you have is that with the current simulation design (n=20, prob=0.01), you have a high probability of getting no points in the first mixture component (the probability of a point being in the second component is 1-0.01=0.99, so the probability that all of the points are in the second component is 0.99^20 = 82%). In this case the MLE will be degenerate (i.e., you're trying to fit a two-component mixture to a data set that essentially only has one component); in this case any of these solutions will give equivalent likelihoods:
- prob=0, mu2=mean of the data, mu1=anything
- prob=1, mu1=mean of the data, mu2=anything
- mu1=mu2=mean of the data, prob=anything
With all these solutions, where you end up will depend very sensitively on starting conditions and optimization algorithm.
For this problem I would encourage you to use the built-in dmixexp2
function from the Renext
package (which correctly implements the log-likelihood as log(p*Prob(X|exp1) + (1-p)*Prob(X|exp2))
) and the formula interface to mle2
:
QUESTION
I am trying to fit my data to Rayleigh distribution by using the fitdist
function from the fitdistrplus
package.
ANSWER
Answered 2021-Jan-27 at 12:13There are two problems. (1) the Rayleigh distribution does not seem to be a good fit to the data (see plot output below) and (2) you need a better starting value. Since sigma is proportional to the mean for the Rayleigh distribution (see wikipedia) try that:
QUESTION
I'm trying to replicate R's fitdist() results (reference, cannot modify R code) in Python using scipy.stats
. The results are totally different. Does anyone know why? How can I replicate R's results in Python?
ANSWER
Answered 2021-Jan-18 at 23:25The discrepancy is mainly due to the differing pdfs.
PythonIn python st.pareto.fit()
uses a Pareto distribution defined via this pdf:
QUESTION
I'm trying to replicate R's fitdist()
results (reference, cannot modify R code) in Python using scipy.stats. The results are quite close but still different (difference is at not acceptable level). Does anybody know why the results are different? How can I reduce the difference between the results?
scipy_stats.weibull_min
definition (https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.weibull_min.html) seems to be the same as R's weibull (https://stat.ethz.ch/R-manual/R-devel/library/stats/html/Weibull.html.
Data example:
...ANSWER
Answered 2021-Jan-14 at 17:01The difference appears to be the result of the default relative tolerances used by the optimizers (and normal floating point imprecision). If you tighten the tolerance in the R calculation, the result is closer to the SciPy result:
QUESTION
I am doing looping for my simulation study. But it did not give a nice output. I want to be able to call out again the output. This is the function inside the looping.
...ANSWER
Answered 2020-Nov-30 at 14:46Since you want to save the data into a data frame I will assume you want jj
to contain the result. As your code stands you probably want to do something like:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mle
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page