Displaying 3 results from an estimated 3 matches for "mavg".
Did you mean:
avg
2004 Dec 10
1
Porting optimisation setup from Excel Solver to R
Hi all,
I am currently optimising a small portfolio I have
created as a part of my research project in Excel. I
am unable to find the appropriate package to port this
into R. My problem set up is as follows
Minimise ABS(Sum(Xi-Xi')+10*Sum(XiMi)/Mavg)
Subject to:
0 <= Xi <= 0.05
ABS(Sum(Xi)) = 0.2
where
Mi - Market Cap of Stock i
Xi - Initial weight of Stock i
Xi' - New weight of Stock i
Mavg = Average weighted market cap of portfolio.
My portfolio has a long as well as a short side,
therefore the ABS. The minimisation function is...
2011 Sep 20
0
Problems using predict from GAM model averaging (MuMIn)
...s(x6,bs="tp",k=3)+x7,data=dat, family="gaussian")
I am trying to follow the example given in the help for "predict.averaging":
I can calculate the top models etc. without problem:
dd<-dredge(gamp)
top.models <- get.models(dd, subset=cumsum(weight) <= .95)
mavg<-model.avg(top.models) # get averaged coefficients
I then calculate means of all the data:
newdata <- as.data.frame(lapply(lapply(dat[1:6], mean), rep, 27))
And use the helper function to get my variable of interest at regular
intervals:
# helper function
nseq <- function(x, len=le...
2014 Jul 28
0
lattice, latticeExtra: Adding moving averages to double y plot
...% c("stuff1"), ]
stuff12_3data <- mydata[(mydata$Type) %in% c("stuff2", "stuff3"), ]
# make moving averages function using zoo and rollmean:
library(zoo)
library(plyr)
f <- function(d)
{
require(zoo)
data.frame(Year = d$Year[5:length(d$Year)],
mavg = rollmean(d$Value, 5))
}
# Apply the function to each group as well as both data frames:
madfStuff1 <- ddply(stuff1data, "Type", f)
madfStuff2_3 <- ddply(stuff12_3data, "Type", f)
# Some styles:
myStripStyle <- function(which.panel, factor.levels, ...) {
panel.rect...