Displaying 20 results from an estimated 6000 matches similar to: "Looking for constrained optimisation code"
2005 Dec 14
1
Glitch when creating online help
_______________________________________________________________________________________
Hi,
I'm writing up the online help for a package I'm developing (in-house
only, sorry), and I've come across an odd glitch when trying to nest a
list inside the "arguments" section of the .Rd file. I was just
wondering if anyone could provide some insights. I'm using R 2.2.0 on
2006 Dec 11
3
Problem with sas.get function in Hmisc
Thomas,
As F Harrel in a preceding message told me that you are the maintainer
of Hmisc package,
I write directly to you, with copy to the Rhelp list in case someone
encountered the same problem and find some benefit in the response.
I used quite often the function sas.get in Hmisc library which I is
very, very useful.
But, as trying to reuse it today it seems not to function anymore.
I tried
2005 Nov 28
3
glm: quasi models with logit link function and binary data
# Hello R Users,
#
# I would like to fit a glm model with quasi family and
# logistical link function, but this does not seam to work
# with binary data.
#
# Please don't suggest to use the quasibinomial family. This
# works out, but when applied to the true data, the
# variance function does not seams to be
# appropriate.
#
# I couldn't see in the
# theory why this does not work.
# Is
2009 Jul 02
2
constrained optimisation in R.
i want to estimate parameters with maximum likelihood method with contraints (contant numbers).
for example
sum(Ai)=0 and sum(Bi)=0
i have done it without the constraints but i realised that i have to use the contraints.
Without constraints(just a part-not complete):
skellamreg_LL=function(parameters,z,design)
{
n=length(z);
mu=parameters[1];
H=parameters[2];
Apar=parameters[3:10];
2005 Nov 16
1
Unexpected result of names<-
_______________________________________________________________________________________
Note: This e-mail is subject to the disclaimer contained at the bottom of this message.
_______________________________________________________________________________________
Hi,
I came across some rather unexpected behaviour the other day with
assigning names and lists. Here's an example.
> z
2007 Jul 04
2
for loop doesn't stop with upper loop value
Hi list,
could anyone please educate me on the following:
lst<-seq(47, 239, by=12)
for(n in lst)
{
lower=n; upper=lower+10
for(i in lower+2 : upper)
{
print(paste(n, " i: ", i, " lower: ",lower, " upper :", upper))
}
}
does not stop when i = upper
A while loop fixes this but, I still don't understand why the for loop
doesn't stop
2005 Nov 23
2
negative binomial overdispersion question
Hello,
I'm a grad student in the Intelligent Transportation Systems lab at Portland
State Univ. in Portland, OR, USA. I'm trying to learn the basics of R to run a
negative binomial in the near future, and so I ran a test regression on roadway
crash data obtained from "Statistical and Econometric Methods for
Transportation Data Analysis" by Washington et al (p. 250). I ran the
2006 Jun 14
3
A question about stepwise procedures: step function
Dear all,
I tried to use "step" function to do model selection, but I got an error massage. What I don't understand is that data as data.frame worked well for my other programs, how come I cannot make it run this time. Could you please tell me how I can fix it?
***************************************************************************************************
2005 Nov 22
4
the matrix of rows with specific row sums
I am just starting with R and have the following problem: given a matrix
of ones and zeroes, say
mdim=4
m<-matrix(round(runif(mdim^mdim)),mdim,mdim)
how to construct the matrix of those rows of m, whose elements sum to 2.
Contrary to the random matrix above, the actual matrix always has at
least one such row.
Serguei Kaniovski
2005 Nov 29
1
rlogis() in simulation
Dear List:
We are generating data such that students are clustered in schools for
some item response data for a simulation study. One component of our
simulation is to generate measurement error from a logistic distribution
with a mean of 0 and standard deviation of 1.7 to match the logistic
curve of the Rasch model.
We are generating an error term for each of the 40 hypothetical test
items a
2007 Mar 07
5
hwo can i get a vector that...
dear all,
how can i get a vector that shows the number of the column of matrix
that contains the maximum of the row ??
can?t believe in need a loop for this...
i have a 100 x 3 matrix and want to get a 100 x 1 vector with values
1,2,3 .
there must be a simple solution. i just cannot find it. i think am
searching on the wrong end.
thx for help in advance.
m.
2011 Sep 08
3
global optimisation with inequality constraints
Dear All,
I would like to minimise a nonlinear function subject to linear inequality constraints as part of an R program. I have been using the constrOptim function. I have tried all of the methods that come with Optim, but nothing finds the correct solution. If I use the correct solution as the vector of starting values, though, my program does output the correct solution and optimum - the
2009 Feb 05
2
Non-linear optimisation
Hi there,
I have a piece of Matlab code I use to optimise a trding strategy. If there
are any Matlab/R specialists out there, I would appreciate your help in
doing the exact same optimisation in R.
I suspect I would use nlm() in R but am not sure where to define my
constraints.
I have attached my Matlab code below for reference.
Many thanks.
Constraints
function [c,ceq]=TriskellConstraints(X)
2007 Jun 21
4
"if" within a function
Dear Friends.
I found a puzzling phenomenon in R when you use 'if' within a function:
# defining a function aaa
aaa=function(a)
{if (a==1) {aaa=1};
if (a!=1) {aaa=2}
}
# using the function:
> b=20
> bbb=aaa(b)
> bbb
[1] 2
> typeof(bbb)
[1] "double"
>
>
> c=1
> ccc=aaa(c)
> ccc
NULL
> typeof(ccc)
[1] "NULL"
It seems that only the last
2006 Nov 16
1
Interaction and factor ':'
_______________________________________________________________________________________
Hello,
Not sure if this counts as a bug or not, but I just noticed in R 2.4.0
that : and interaction are not quite equivalent. For example:
> x <- factor(letters[1:4])
> y <- factor(letters[11:14])
> x:y
[1] a:k b:l c:m d:n
Levels: a:k a:l a:m a:n b:k b:l b:m b:n c:k c:l c:m c:n d:k d:l d:m
2005 Dec 06
5
Matrix of dummy variables from a factor
What is a simple way to convert a factor into a matrix of dummy variables?
fm<-lm(y~f)
where f is a factor takes care of this in the estimation. I'd like to
save the result of expanding f into a matrix for later use.
Thanks.
Charles
--
Charles H. Franklin
Professor, Political Science
University of Wisconsin, Madison
franklin at polisci.wisc.edu
chfrankl at wisc.edu
2005 May 20
3
constrained optimization
Hello,
I've got to compute a minimization equation under an equality constraint
(Min g(x1,x2,x3) with x1+x2=const). The Constroptim function does not
authorize an equality condition but only inequality conditions. Which
function can I use instead?
Thank you very much for your help.
Gael Robert - +33 1 42 14 27 96
******************************************************************
This
2006 Oct 30
3
plot history
_______________________________________________________________________________________
Hi,
When I create multiple graphs subsequent graphs overwrite previous
graphs. How do I keep all my graphs in the current workspace (but not
all on the same page) so I can scroll through them?
thanks,
Rohini
Rohini Mulford
Senior Research Analyst
Technical Research
Research &
2009 Jan 28
2
constrainOptim
Dear R helpers
I have a question regarding the constrainOptim.
I'm coding the nested logit and would like to set a bound of rho to (0,1] as an extreme value distribution where rho = exp(lambda)/1+exp(lambda)
I wonder if I can do that directly in optim (say rho > 0 & <= 1) or need to use constrainOptim
I read the help but still don't know how to set ui and ci
Thanks,
June
2009 Sep 11
1
constrOptim parameters
Dear R wizards: I am playing (and struggling) with the example in the
constrOptim function. simple example. let's say I want to constrain my
variables to be within -1 and 1. I believe I want a whole lot of
constraints where ci is -1 and ui is either -1 or 1. That is, I have 2*N
constraints. Should the following work?
N=10
x= rep(1:N)
ci= rep(-1, 2*N)
ui= c(rep(1, N), rep(-1, N))