Re: [R] questions about optim

About this list Date view Thread view Subject view Author view Attachment view

From: Spencer Graves (spencer.graves@pdf.com)
Date: Sun 16 May 2004 - 06:38:38 EST


Message-id: <40A67FCE.6030807@pdf.com>


      1. Have you considered parameterizing the problem in terms of
(Theta1, Theta2, Theta3), and then computing Theta4 <-
(1-Theta1-Theta2-Theta3) in the function you ask "optim" to optimize?

      2. Beyond this, I don't understand what you are trying to do. Do
you want to estimate a multinomial approximation to a normal
distribution? If yes, are you given the mean and standard deviation of
the normal distribution PLUS the break points? If yes, then what about
the following:

> Breaks <- 1:3
> Mean <- 0
> Sd <- 1
> Theta1 <- pnorm((Breaks[1]-Mean)/Sd)
> Theta2 <- (pnorm((Breaks[2]-Mean)/Sd)-Theta1)
> Theta3 <- (pnorm((Breaks[3]-Mean)/Sd)-Theta2)
> Theta4 <- pnorm((Breaks[3]-Mean)/Sd, lower.tail=FALSE)
> Breaks <- 1:3
> Mean <- 0
> Sd <- 1
> Theta1 <- pnorm((Breaks[1]-Mean)/Sd)
> Theta2 <- (pnorm((Breaks[2]-Mean)/Sd)-Theta1)
> Theta3 <- (pnorm((Breaks[3]-Mean)/Sd)-Theta2)
> Theta4 <- pnorm((Breaks[3]-Mean)/Sd, lower.tail=FALSE)
> Theta1;Theta2;Theta3;Theta4
[1] 0.8413447
[1] 0.1359051
[1] 0.862745
[1] 0.001349898
 
       hope this helps. spencer graves

Dean Lee wrote:

> Hi,
> I am trying to do parameter estimation with optim, but I can't get it
> to work quite right-- I have an equation X = Y where X is a gaussian,
> Y is a multinomial distribution, and I am trying to estimate the
> probabilities of Y( the mean and sd of X are known ), Theta1, Theta2,
> Theta3, and Theta4; I do not know how I can specify the constraint
> that Theta1 + Theta2 + Theta3 + Theta4 = 1 in optim. Is there another
> method/package that I should use for this?
> Also, I wonder if there's a more elegant way to code this equation in
> R; right now my function looks something like Y/rnorm( 10000, mean,
> sd), and I try to maximize it to 1; is it possible to "plug" the
> entire gaussian( instead of using rnorm ) into the equation? Thanks.
>
> Regards,
>
> -Dean
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:11 EST