s-news
[Top] [All Lists]

nlminb with constraint

To: s-news <s-news@lists.biostat.wustl.edu>
Subject: nlminb with constraint
From: "John Pitchard" <johnpitchard@googlemail.com>
Date: Mon, 7 Apr 2008 15:40:42 +0100
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=QH7u2TQAgnR0FeGoOdNQ0hSaWqcstF8RKkAldpB51sI=; b=l5lj8Z553QoD5VZ2WXUSxUNnLcTlD13d7lokpPxXdxJ8/3U/KPItA867DwDY6yjhbG3c6WSeNTAoxaXYvo1WApU7VIo2bnv/apMSLWMMRyRNqwcvQxVP+kdbJ49/rkh78I2ZbgZ//c5a1iE4/G8h/JyXUMLpcw5DVYuGjqkmovQ=
Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=WYdLXKemoavLGuEuRDDF2+ddfALxGvP2soFrEwOxT56F+Wfq1tG1IgShLTAzBwr18/hbGSxLnn8WtZHrTDTn/YywZYnO/009xnRo7A2dfMr/glrEgGgVevUCvYEo8nqba4qH4sc0tcut3yJEWP6YPdYA77UZavks8GUc8Fq5pZU=
Dear All,
 
I wanted to post some more details about the query I sent to s-news last week.
 
I have a vector with a constraint. The constraint is that the sum of the vector must add up to 1 - but not necessarily positive, i.e.

x[n] <- 1 -(x[1] + ...+x[n-1])
 
I perform the optimisation on the vector x such that 
 
x <- c(x, 1-sum(x))
 
In other words,
 
fn <- function(x){
  x <- c(x, 1 - sum(x))
  # other calculations here
}

then feed this into nlminb()

out <- nlminb(x, fn)
out.x <- out$parameters
out.x <- c(out.x, 1 - sum(out.x))
out.x
 
I would like to calculate standard errors for each of the components of x. Is this possible by outputing the Hessian matrix? Furthermore, how would I calculate this for the last component (if this is indeed possible) which has the restriction (i.e. 1-sum(out.x))?
 
Any help would be much appreciated.
 
Regards,
John 
<Prev in Thread] Current Thread [Next in Thread>
  • nlminb with constraint, John Pitchard <=