Displaying 20 results from an estimated 2000 matches similar to: "vectorized mle / optim"
2004 Jun 10
1
overhaul of mle
So, I've embarked on my threatened modifications to the mle subset
of the stats4 package. Most of what I've done so far has *not* been
adding the slick formula interface, but rather making it work properly
and reasonably robustly with real mle problems -- especially ones
involving reasonably complex fixed and default parameter sets.
Some of what I've done breaks backward
2019 Apr 24
1
Bug in "stats4" package - "confint" method
Dear R developers,
I noticed a bug in the stats4 package, specifically in the confint method applied to ?mle? objects.
In particular, when some ?fixed? parameters define the log likelihood, these parameters are stored within the mle object but they are not used by the ?confint" method, which retrieves their value from the global environment (whenever they still exist).
Sample code:
>
2006 Sep 08
1
maximizing a likelihood function containing an integral
Hi, R Users;
I am trying to maximize a likelihood function which
contains an integral. The integral contains the
unknown parameter as well. I am trying to use the
following code to do the maximization:
ll<-function(b.vec){
b0<-b.vec[1]
b1<-b.vec[2]
b2<-b.vec[3]
p<-1/(1+exp(-b0-b1*z1-b2*x2))
2006 Feb 02
2
how to use mle?
>Y
[,1] [,2] [,3]
[1,] 0 1 0
[2,] 0 1 0
[3,] 0 0 1
[4,] 1 0 0
[5,] 0 0 1
[6,] 0 0 1
[7,] 1 0 0
[8,] 1 0 0
[9,] 0 0 1
[10,] 1 0 0
>X
pri82 pan82
1 0 0
2 0 0
3 1 0
4 1 0
5 0 1
6 0 0
7 1 0
8 1 0
9 0 0
10
2011 May 23
6
Reading Data from mle into excel?
Hi there,
I ran the following code:
vols=read.csv(file="C:/Documents and Settings/Hugh/My Documents/PhD/Swaption
vols.csv"
, header=TRUE, sep=",")
X<-ts(vols[,2])
#X
dcOU<-function(x,t,x0,theta,log=FALSE){
Ex<-theta[1]/theta[2]+(x0-theta[1]/theta[2])*exp(-theta[2]*t)
Vx<-theta[3]^2*(1-exp(-2*theta[2]*t))/(2*theta[2])
dnorm(x,mean=Ex,sd=sqrt(Vx),log=log)
}
2005 Jul 21
1
About object of class mle returned by user defined functions
Hi,
There is something I don't get with object of class "mle" returned by a
function I wrote. More precisely it's about the behaviour of method
"confint" and "profile" applied to these object.
I've written a short function (see below) whose arguments are:
1) A univariate sample (arising from a gamma, log-normal or whatever).
2) A character string
2011 Feb 22
2
mle
Hi,
I am looking for some help regarding the use of the mle function.
I am trying to get mle for 3 parameters (theta0, theta1 and theta2) that
have been defined in the the log-likelihood equation as theta0=theta[1],
theta1=theta[2] and theta2=theta[3].
My R code for mle is:
mle(Poisson.lik, start=list(theta=c(20,1,1), method="Nelder-Mead",
fixed=list(w=w, t1=t1, t2=t2))
But I keep
2012 Oct 19
2
likelihood function involving integration, error in nlm
Dear R users,
I am trying to find the mle that involves integration.
I am using the following code and get an error when I use the nlm function
d<-matrix(c(1,1,0,0,0,0,0,0,2,1,0,0,1,1,0,1,2,2,1,0),nrow=10,ncol=2)
h<-matrix(runif(20,0,1),10)
integ<-matrix(c(0),nrow=10, ncol=2)
ll<-function(p){
for (k in 1:2){
for(s in 1:10){
integrand<-function(x)
2006 Jun 23
1
How to use mle or similar with integrate?
Hi
I have the following formula (I hope it is clear - if no, I can try to
do better the next time)
h(x, a, b) =
integral(0 to pi/2)
(
(
integral(D/sin(alpha) to Inf)
(
(
f(x, a, b)
)
dx
)
dalpha
)
and I want to do an mle with it.
I know how to use mle() and I also know about integrate(). My problem is
to give the parameter values a and b to the
2008 Feb 28
4
standard errors
Hi, guess my problem has simple solution.
I want to extract ONLY Std. Errors of Max. Lik. estimates
(my_fit<-mle(object,...)), the same as I can do with estimates by:
x<-as. matrix(coef(my_fit)).
I could not find any function similar to 'coef(my_fit)', which extracts only
Standard Errors. So far all I can do is to type: summary(my_fit) and then
get the whole output (with Standard
2010 Dec 16
1
Optim function with meta parameters
Hi guys.
I have a dataset with 4 columns. In the first and second column I have the
same qualitative variable referred to different teams of people. There are
10 teams in total and they compete against each other to perform a certain
task whose result is stored in the third column for the team recorded in the
first column, and in the fourth column for the team in the second column.
For example,
2009 Jan 05
2
Sweave data-figure coupling
Hi,
With the following Sweave minimal file:
---<--------------------cut here---------------start------------------->---
\documentclass{article}
\usepackage{Sweave}
\begin{document}
<<binom-sim>>=
thetas <- seq(0, 1, by=0.001)
prior <- rep(1, length(thetas)) / length(thetas)
lik <- dbinom(1, 1, thetas)
lik.p <- prior * lik
post <- lik.p / sum(lik.p)
2011 Mar 19
2
problem running a function
Dear people,
I'm trying to do some analysis of a data using the models by Royle & Donazio
in their fantastic book, particular the following function:
http://www.mbr-pwrc.usgs.gov/pubanalysis/roylebook/panel4pt1.fn
that applied to my data and in the console is as follows:
> `desman.y` <- structure(c(3L,4L,3L,2L,1L), .Names = c("1", "2", "3",
2010 Jul 22
1
function return
I am sorry if this question is vague or uninformed. I am just
learning R and struggling. I am using the book Hierarchical Modeling
and Inference in Ecology and they provide examples of R code. I have
the following code from the book but when I run it I don't get any
output. I cannot get the values of 'out' to show up. Basically, I
just want to see my estimates for b0,
2012 Aug 08
1
dimnames in array
Hello,
I'm working with an array; I'm trying to make it so that an array of
dim(42,2,2) has names whose length corresponds to that of the array,
and am hoping someone with experience with this can see what I'm not
doing correctly:
data11 = array(0,c(41,2,2))
y = lsoda(x0,times,fhn$fn.ode,pars)#This is make.fhn() from colloc
infer package#
y = y[,2:3]
2006 Feb 07
1
sampling and nls formula
Hello,
I am trying to bootstrap a function that extracts the log-likelihood value and the nls coefficients from an nls object. I want to sample my dataset (pdd) with replacement and for each sampled dataset, I want to run nls and output the nls coefficients and the log-likelihood value.
Code:
x<-c(1,2,3,4,5,6,7,8,9,10)
y<-c(10,11,12,15,19,23,26,28,28,30)
pdd<-data.frame(x,y)
2003 Jan 15
2
Bug or Feature? LogLik.nls and non-central F distribution.
I have a dataset that I am running non-linear regression on via the
following code:
Hill <- function(E0,Em,C50,g,C){
#
# Hill is the hill interaction function.
#
# E0 Represents the minimum interaction Effect
#
# Em Represents the Maximum Interaction Effect
#
# C50 represents the concentration at which 50% of the effect occurs.
#
# gamma represents the cooperativity of the
2007 Mar 06
2
Estimating parameters of 2 phase Coxian using optim
Hi,
My name is Laura. I'm a PhD student at Queen's University Belfast and have
just started learning R. I was wondering if somebody could help me to see
where I am going wrong in my code for estimating the parameters [mu1, mu2,
lambda1] of a 2-phase Coxian Distribution.
cox2.lik<-function(theta, y){
mu1<-theta[1]
mu2<-theta[2]
lambda1<-theta[3]
2005 Nov 11
1
optim not giving correct minima
Hello,
I am trying to use optim() on a function involving a summation. My
function basically is a thinned poisson likelihood. I have two parameters
and in most cases optim() does a fine job of getting the minima. I am
simulating my data based on pre specified parameters, so I know what I
should be getting. However when my true parameters fall in a particular
range, optim() gives
2005 Jul 27
1
Problem specifying "function" for "mle" operation
Hello fellow R users,
Below are two cases using the "mle" operation from the stats4 package. In CASE 1 the code runs fine, in CASE 2 errors occur:
CASE 1
x, alpha_current, s, and n are vectors of the same length.
ll_beta<-function(b0=0,b1=0) -sum(s*b0+s*b1*x+s*alpha_current-n*log(1+exp(b0+b1*x+alpha_current)))
fit_beta<-mle(ll_beta)
CASE 2
The error message is as follows