Displaying 20 results from an estimated 800 matches similar to: "Ever see a stata import problem like this?"
2018 May 03
4
adding overall constraint in optim()
Hi ?
This is giving me a headache. I?m trying to do a relatively simple optimization ? actually trying to approximate the output from the Excel Solver function but at roughly 1000x the speed. ?
The optimization parameters look like this. The only trouble is that I want to add a constraint that sum(wgt.vect)=1, and I can?t figure out how to do that in optim.
Mo.vect <-
2010 Feb 02
2
Subset and plot
Here is a runable program. When I plot Day and Wgt, it graphs all the data
points. All I need is daily.sub1 plotted. I also need each "Tanks" to have
its own col or pch. When I run it with the line with pch, it gives me
nothing.
rm(list=ls())
Trial<-rep(c(1,2),each=12)
Tanks=rep(c("a3","a4","c4","h4"),each=3,2)
Day=rep(c(1:12),2)
2018 May 06
1
adding overall constraint in optim()
Hi Michael,
A few comments
1. To add the constraint sum(wgt.vect=1) you would use the method of
Lagrange multipliers.
What this means is that in addition to the w_i (the components of the
weight variables) you would add an additional variable, call it lambda.
Then you would modify your optim.fun() function to add the term
lambda * (sum(wgt.vect - 1)
2. Are you sure that you have defined
2018 May 03
0
adding overall constraint in optim()
You can't -- at least as I read the docs for ?optim (but I'm pretty
ignorant about this, so maybe there's a way to tweak it so you can).
See here: https://cran.r-project.org/web/views/Optimization.html
for other R optimization capabilities.
Also, given your credentials, the r-sig-finance list might be a
better place for you to post your query.
Cheers,
Bert
Bert Gunter
2018 May 03
2
adding overall constraint in optim()
Thanks Bert. But everyone on that forum wants to use finance tools rather than general optimization stuff! And I am not optimizing a traditional Markowitz mean-variance problem. Plus, smarter people here. :-)
> On May 3, 2018, at 3:01 PM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
>
> You can't -- at least as I read the docs for ?optim (but I'm pretty
> ignorant
2018 May 04
0
adding overall constraint in optim()
On Thu, May 3, 2018 at 2:03 PM, Michael Ashton
<m.ashton at enduringinvestments.com> wrote:
> Thanks Bert. But everyone on that forum wants to use finance tools rather than general optimization stuff! And I am not optimizing a traditional Markowitz mean-variance problem. Plus, smarter people here. :-)
>
I'm very confused by these statements. Most of the "finance tools"
2009 May 31
1
Bug in gmodels CrossTable()?
Is the code below showing a bug in Crosstable()? My expectation was that
the values produced by xtabs were rounded instead of truncated:
library(gmodels)
abc <- c("a", "a", "b", "b", "c", "c")
def <- c("d", "e", "f", "f", "d", "e")
wgt <- c(0.8, 0.6, 0.4, 0.5, 1.4, 1.3)
2010 Feb 02
1
Subset and point plot
OK, I need help plotting. I have column headings of Day, Wgt, Foodin, Rep,
Grp and Tanks. Rep=c(1,2,3) and Tanks=c(a1,a2,a3,a4,a5,a6,
c1,c2,c3,c4,c5,c6, h1,h2,h3,h4,h5,h6).
I created a subset where I only would like Rep=2, and Tanks=c(a4,c4,h4) and
would like to graph (points) of Wgt and Day. I would think that I only need
3 colors, but when I run with only 3, only 2 lines show up. When I add
2006 Apr 19
1
Trouble with glm() .... non-integer #successes in a binomial glm
Hi R-people:
When I use the command to fit a model with an intercept, only:
glm ( formula=haspdata ~ 1, data=dat, family=binomial, weights=
dat$hy.wgt.s, subset=(dat$haspdat0!=3) )
I get the message:
Warning message:
non-integer #successes in a binomial glm! in: eval(expr, envir, enclos)
Does anyone know what this means?? The data for this command is listed
below.
Thanks,
Phil Smith
CDC
2009 Nov 14
4
Weighted descriptives by levels of another variables
I've noticed that R has a number of very useful functions for
obtaining descriptive statistics on groups of variables, including
summary {stats}, describe {Hmisc}, and describe {psych}, but none that
I have found is able to provided weighted descriptives of subsets of a
data set (ex. descriptives for both males and females for age, where
accurate results require use of sampling
2018 May 05
1
adding overall constraint in optim()
Hi,
You can use the projectLinear argument in BB::spg to optimize with linear equality/inequality constraints.
Here is how you implement the constraint that all parameters sum to 1.
require(BB)
spg(par=p0, fn=myFn, project="projectLinear", projectArgs=list(A=matrix(1, 1, length(p0)), b=1, meq=1))
Hope this is helpful,
Ravi
[[alternative HTML version deleted]]
2008 Feb 29
1
barplot and pca plot in mvpart/rpart
Hello,
I'm using the R package called mvpart, which is about the multivariate
regression trees.
The function I wrote is:
mrt1<- mvpart(coefmat~sChip+sScreen+sMem,data=mixdata, xv="pick",
plot.add=TRUE,uniform=TRUE,which=4,all=TRUE,xadj=2,yadj=2,rsq=TRUE,big.pts=TRUE,wgt.ave.pca=TRUE,legend=TRUE,bars=F,
pca=TRUE)
where "coefmat" is a matrix(of dimension N*K) to store
1999 Apr 28
2
smbmount doesn't work
Hi,
Thanks for answering my question on the new smbmount not working. I tried
all variety of combinations on the commands you suggested, but they all
simply do this:
% smbmount -c //server/share 'mount /mnt/samba-share -n CLIENT -U user'
Usage: smbmount service <password> [-p port] [-d debuglevel] [-l log]
Version 2.0.3
-p port connect to the specified port
2003 May 31
0
logistic regression
hi all,
I am fitting a logistic regression model on binary data. I care about
the fitted probabilities, so I am not worried about infinite
(or non-existent) MLEs. I use:
> glm(Y~., data=X, weights=wgt, family=binomial(link=logit), maxit=250)
I understand the three ways to fit model, and in my case Y is a factor,
one column
> Y <- c(rep("A",679), rep("B",38))
2003 May 31
0
logistic regression (weights)
hi all,
I am fitting a logistic regression model on binary data. I care about
the fitted probabilities, so I am not worried about infinite
(or non-existent) MLEs. I use:
> glm(Y~., data=X, weights=wgt, family=binomial(link=logit), maxit=250)
I understand the three ways to fit model, and in my case Y is a factor,
one column
> Y <- c(rep("A",679), rep("B",38))
2010 Sep 27
3
Alphabetical sequence of data along the x-axis in a box plot
Hello All,
I noticed when I generated some boxplots, the data is presented in
alphabetical order along the x-axis (the data in this case was the four
quandrants of a sample area (NE,NW, SE, SW) that was my first column of
data). Is there a way to have R plot the data in a different order? I
imagine you could use a dummy variable, but didn't know if there might
be a simple argument that
2008 Jun 24
2
logistic regression
Hi everyone,
I'm sorry if this turns out to be more a statistical question than one
specifically about R - but would greatly appreciate your advice anyway.
I've been using a logistic regression model to look at the relationship
between a binary outcome (say, the odds of picking n white balls from a bag
containing m balls in total) and a variety of other binary parameters:
2007 Oct 10
0
Warning message when using "reldist" package
Dear R users,
I'm using the "reldist" add-on package to calculate relative distribution in R as part of my research project. The subject is a general mental health score ranging from 0 to 12 (integer values only) with 0 indicating no mental health problem and positive values meaning some or sever mental health problem.
When I run the programme to compare the scores of population
2005 Mar 03
3
3d plot of regression squared error
Hi. I'm trying to create a 3d plot for a teaching example of finding a
least-squares estimate of the parameters to fit a line to some data. I
was hoping to get a nice plot with a clear, single minima where the
derivative of the surface is zero. No matter how much I tinker, I can't
seem to get a simple straightforward plot. Am I doing something wrong?
Thanks in anticipation,
Ross-c
x
2009 May 20
2
drc results differ for different versions
Hello,
We use drc to fit dose-response curves, recently we discovered that
there are quite different standard error values returned for the same
dataset depending on the drc-version / R-version that was used (not
clear which factor is important)
On R 2.9.0 using drc_1.6-3 we get an IC50 of 1.27447 and a standard
error on the IC50 of 0.43540
Whereas on R 2.7.0 using drc_1.4-2 the IC50 is