Displaying 20 results from an estimated 26 matches for "theta0".
Did you mean:
theta
2007 Jul 21
1
Gamma MLE
Hello,
I was asked to try the following code on R,
gamma.mles
function (xx,shape0,rate0)
{
n<- length(xx)
xbar<- mean(xx)
logxbar<- mean(log(xx))
theta<-c(shape0,rate0)
repeat {
theta0<- theta
shape<- theta0[1]
rate<- theta0[2]
S<- n*matrix(c(log(rate)-digamma(shape)+logxbar,shape/rate-xbar),ncol=1)
I<- n*matrix(c(trigamma(shape),-1/rate,-1/rate,shape/rate^2),ncol=2)
theta<- theta0 + solve(I) %*% S
if(max(abs(theta-theta0)) < 1e-08)
break
}
list(estimates=the...
2011 Jun 18
2
different results from nls in 2.10.1 and 2.11.1
...7636414, 0.7919752597809, 0.9539568424225, 0.4840737581253,
0.850653231144, 0.5909016132355, 0.8414449691772, 0.9699150323868)
xlims <- c(-1,1)
bw <- 0.05
b <- seq(xlims[1],xlims[2],by=bw) ; nb <- length(b)
h <- hist( dd, breaks=b, plot=FALSE)
FisherAvgdPdf <- function(theta,theta0,kappa){
A <- kappa/(2*sinh(kappa))
A * I.0( kappa*sin(theta)*sin(theta0) ) * exp(
kappa*cos(theta)*cos(theta0) )
}
nls(dens ~ FisherAvgdPdf(theta,theta0,kappa),
data = data.frame( theta=acos(h$mids), dens=h$density ),
start=c( theta0=0.5, kappa=4.0 ),
algorithm="port...
2006 Nov 11
2
Bayesian question (problem using adapt)
...r density for a Bayesian
survival model with four parameters. However, when I try to use the adapt
function to perform integration in four dimensions (on my old version of R
I get an error message saying that I have applied a non-function, although
the function does work when I type kernel2(param0, theta0), or on the
newer version of R the computer crashes.
I have attached the following R code:
hazard1 <- function(x, param) {
if(min(x, param)<=0) {return("function undefined")}
return(param[1]*x^(param[2] -1))
}
gm <- function( theta, param) {
dgamma(param[1], shape = .1, s...
2011 Feb 21
0
Function within functions and MLE
...are represented by the summations in the above
equation.
My R code is as follows
te <-
c(11,161,337,684,1075,1639,2021,2325,2715,3052,3711,3928,4417,4808,5527,6489,6832,7641,8074)
G <-
c(106,164,314,350,523,317,281,378,327,578,201,427,338,682,952,337,803,424,0)
Poisson.lik <- function(theta0, theta1, theta2, w, t1, t2) {
X <- array(0, dim=c(1,19))
for (i in 1:19) {
X[i] <- function(theta0, theta1, theta2, w, t1, t2)
(((theta0*w*t2)-(theta1*cos(w*t2))+(theta2*sin(w*t2)))/w) -
(((theta0*w*t1)-(theta1*cos(w*t1))+(theta2*sin(w*t1)))/w)
}
XX <- -sum(X)
Y <- array(0, dim=c...
2008 Mar 19
1
problem with optim and integrate
...te(numint, lower = -Inf, upper = Inf) :
non-finite function value."
My questions are
How could I fix it? I tried to divide into several intervals and sum up, but
I got same message.
My code is
-----------------------------------------------------------------------------------
alpha=1.3; theta0=c(0.5,0,sqrt(10),0.25,-.3,sqrt(0.05),.3,sqrt(0.05))
fc = function(theta){
numint = function(z)
{
(theta[1]*dnorm(z,mean=theta[2],sd=theta[3])+theta[4]*dnorm(z,mean=theta[5],sd=theta[6])
+(1-(theta[1]+theta[4]))*dnorm(z,mean=theta[7],sd=theta[8]))^alpha
}
inte = integ...
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 getting the followin...
2013 Apr 08
0
Maximum likelihood estimation of ARMA(1,1)-GARCH(1,1)
...= omega/(1-alpha-beta)
for (t in 2:n)
{h[t]= omega+ alpha*(u[t-1]^2)+ beta*h[t-1]}
#return(-sum(dnorm(u[2:n], mean=mean, sd=sqrt(h[2:n]), log=TRUE)))
pi=3.141592653589793238462643383279502884197169399375105820974944592
return(-sum(-0.5*log(2*pi) -0.5*log(h[2:n]) -0.5*(u[2:n]^2)/h[2:n]))
}
#theta0=c(0, +0.78, -0.79, +0.0000018, +0.06, +0.93, 0.01)
theta0=rep(0.01,6)
negative_log_likelihood_arma11_garch11(theta=theta0, data=raw_data)
alpha= proc.time()
maximum_likelihood_fit_arma11_garch11=
nlm(negative_log_likelihood_arma11_garch11,
p=theta0,
data=raw_data,
hessian=TRUE,
it...
2011 Aug 13
3
optimization problems
Dear R users
I am trying to use OPTIMX(OPTIM) for nonlinear optimization.
There is no error in my code but the results are so weird (see below).
When I ran via OPTIM, the results are that
Initial values are that theta0 = 0.6 1.6 0.6 1.6 0.7. (In fact true vales
are 0.5,1.0,0.8,1.2, 0.6.)
--------------------------------------------------------------------------------------------
> optim(par=theta0, fn=obj.fy, method="BFGS", control=list(trace=1,
> maxit=10000), hessian=T)
initial value -0.027644...
2008 Apr 05
2
How to improve the "OPTIM" results
...0.43739341, -0.02416010, 4.02788119, 0.07320802,
-0.29393054,
0.25184609, 0.76044448, -3.34121918, 1.16028677, -0.60352008,
-2.86454069,
-0.84411691, 0.24841071, -0.11764954, 5.92662106, 1.03932953,
-6.21987657,
-0.54763352, 0.20263192) # data
theta0= c(log(2),0,c(0,-.3,.3),log(c(10,.05,.05))) # initial value(In fact,
true parameter value)
n = length(x)
fr2 = function(theta)
{
a1 = theta[1]; a2 = theta[2]
mu1 = theta[3]; mu2 = theta[4]; mu3 = theta[5]
g1 = theta[6]; g2 = theta[7]; g3 = theta[8]
w1=exp(a1)/(1+exp(a1)+exp(a2))
w2=exp(a2...
2008 Apr 05
2
How to improve the "OPTIM" results
...0.43739341, -0.02416010, 4.02788119, 0.07320802,
-0.29393054,
0.25184609, 0.76044448, -3.34121918, 1.16028677, -0.60352008,
-2.86454069,
-0.84411691, 0.24841071, -0.11764954, 5.92662106, 1.03932953,
-6.21987657,
-0.54763352, 0.20263192) # data
theta0= c(log(2),0,c(0,-.3,.3),log(c(10,.05,.05))) # initial value(In fact,
true parameter value)
n = length(x)
fr2 = function(theta)
{
a1 = theta[1]; a2 = theta[2]
mu1 = theta[3]; mu2 = theta[4]; mu3 = theta[5]
g1 = theta[6]; g2 = theta[7]; g3 = theta[8]
w1=exp(a1)/(1+exp(a1)+exp(a2))
w2=exp(a2...
2023 Aug 20
1
Issues when trying to fit a nonlinear regression model
Oh, sorry; I changed signs in the model, fitting
theta0 + theta1*exp(theta2*x)
So for theta0 - theta1*exp(-theta2*x) use theta1= -.exp(-1.8) and theta2 =
+.055 as starting values.
-- Bert
On Sun, Aug 20, 2023 at 11:50?AM Paul Bernal <paulbernal07 at gmail.com> wrote:
> Dear Bert,
>
> Thank you so much for your kind and valuable fe...
2010 Apr 08
1
a small question about R with Winbugs
...[1]
for (j in 2:C) {p[j] <- r[j]*(1-r[j-1])*p[j-1]/r[j-1]}
p.sum <- sum(p[])
for (j in 1:C) {r[j] ~ dbeta(1,alpha); pi[j] <- p[j]/p.sum}
# Baseline distribution
for (j in 1:C) {mu.star[j,1:2] ~
dmnorm(theta[],tau.star[j,,]);tau.star[j,1:2,1:2] ~ dwish(T[,],3)}
theta[1:2] ~ dmnorm(theta0[],S2[,])
T[1:2,1:2] ~ dwish(S3[,],3)
# DPP Precision Parameter
alpha ~ dgamma(1,1)
# Programming for calculating summary statistics
for(i in 1:N) {for (j in 1:C) {SC[i,j] <- equals(j,S[i])}}
# total clusters K
for (j in 1:C) {cl[j] <- step(sum(SC[,j])-1)}
K <- sum(cl[])
}...
2011 Aug 29
3
gradient function in OPTIMX
...hen I use OPTIM with BFGS, I've got a significant result without an error
message. However, when I use OPTIMX with BFGS( or spg), I've got the
following an error message.
----------------------------------------------------------------------------------------------------
> optimx(par=theta0, fn=obj.fy, gr=gr.fy, method="BFGS",
> control=list(maxit=10000))
Error: Gradient function might be wrong - check it!
----------------------------------------------------------------------------------------------------
I checked and checked my gradient function line by line. I coul...
2023 Aug 20
1
Issues when trying to fit a nonlinear regression model
...degrees of freedom
Multiple R-squared: 0.717, Adjusted R-squared: 0.696
F-statistic: 33 on 1 and 13 DF, p-value: 6.76e-05
Kind regards,
Paul
El dom, 20 ago 2023 a las 14:07, Bert Gunter (<bgunter.4567 at gmail.com>)
escribi?:
> Oh, sorry; I changed signs in the model, fitting
> theta0 + theta1*exp(theta2*x)
>
> So for theta0 - theta1*exp(-theta2*x) use theta1= -.exp(-1.8) and theta2 =
> +.055 as starting values.
>
> -- Bert
>
>
>
>
>
> On Sun, Aug 20, 2023 at 11:50?AM Paul Bernal <paulbernal07 at gmail.com>
> wrote:
>
>> Dear Be...
2023 Aug 20
1
Issues when trying to fit a nonlinear regression model
...7, Adjusted R-squared: 0.696
> F-statistic: 33 on 1 and 13 DF, p-value: 6.76e-05
>
> Kind regards,
> Paul
>
> El dom, 20 ago 2023 a las 14:07, Bert Gunter (<bgunter.4567 at gmail.com>)
> escribi?:
>
>> Oh, sorry; I changed signs in the model, fitting
>> theta0 + theta1*exp(theta2*x)
>>
>> So for theta0 - theta1*exp(-theta2*x) use theta1= -.exp(-1.8) and theta2
>> = +.055 as starting values.
>>
>> -- Bert
>>
>>
>>
>>
>>
>> On Sun, Aug 20, 2023 at 11:50?AM Paul Bernal <paulbernal07 at gma...
2004 Feb 16
0
error in nls, step factor reduced below minFactor
Hello,
I am trying to estimate 4 parameters of a non-linear
model using nls.
My model function is a Fourier integral and is very
expensive to
calculate. I get the following error:
> theta0 <- c(0.045, 1.02*10^(-4), 0.00169,
5.67*10^(-4))
> res <- nls(log(y) ~ log(model(theta,r,t)),
data=dataModel,
+ start=list(theta=theta0), trace=TRUE,
+ control=nls.control(tol=1e-2))
20.03975 : 0.045000 0.000102 0.001690 0.000567
13.96798 : 0.0080957877 0.0001002399 0.0009541090...
2011 Aug 29
0
Error: Gradient function might be wrong ----- in OPTIMX
Dear R users
When I use OPTIMX with BFGS, I've got the following error message.
-----------------------------------------------------------------
> optimx(par=theta0, fn=obj.fy, gr=gr.fy, method="BFGS")
Error: Gradient function might be wrong - check it!
-----------------------------------------------------------------
So, I checked and checked my gradient function line by line. However, I
could not find anything wrong.
When I remove the gradient,...
2010 Jul 20
0
Maximum likelihood estimation in R
...to do maximum likelihood estimation in R. I use the "optim" function. Since I have no prior information on the true values of the parameters, I just randomly select different sets of starting values to feed into the program. Each time, I get the following error message: Error in optim(theta0, lf, method = "BFGS", hessian = T, Y = Y, X = X, : non-finite finite-difference value [6]
In addition: There were 50 or more warnings (use warnings() to see the first 50)
I guess this has something to do with the starting values that I chose. But I have no idea as to how to pick better...
2023 Aug 20
2
Issues when trying to fit a nonlinear regression model
...rt Gunter (<bgunter.4567 at gmail.com>)
escribi?:
> I got starting values as follows:
> Noting that the minimum data value is .38, I fit the linear model log(y -
> .37) ~ x to get intercept = -1.8 and slope = -.055. So I used .37,
> exp(-1.8) and -.055 as the starting values for theta0, theta1, and theta2
> in the nonlinear model. This converged without problems.
>
> Cheers,
> Bert
>
>
> On Sun, Aug 20, 2023 at 10:15?AM Paul Bernal <paulbernal07 at gmail.com>
> wrote:
>
>> Dear friends,
>>
>> This is the dataset I am currently wo...
2004 Mar 30
0
koq.q ---- Kent O' Quigley R2
...Obs Events Model L.R. d.f. P Score Score P
26 12 14.29 1 2e-04 12.26 5e-04
R2
0.454
coef se(coef) z p
age 0.162 0.0497 3.25 0.00116
>koq(fit)
Beta = 0
Beta1 = 0.1616199
Error in ELL(theta = theta0, theta1 = theta1, x = x) :
only 0's may mix with negative subscripts
In addition: Warning message:
Replacement length not a multiple of the elements to replace in matrix(...)
-------------- next part --------------
"koq"<-
function(beta1, x = NULL, p = NULL, verbose = T)
{...