[R] RQuantLib: SET_VECTOR_ELT() can only be applied to a 'list', not a 'symbol'

2012-08-08 Thread Cren
# Hi all,
# trying to run the following example code
# from 'RQuantLib' package...

HullWhite - list(term = 0.055, alpha = 0.03, sigma = 0.01,
  gridIntervals = 40)

Price - rep(as.double(100),24)
Type - rep(as.character(C), 24)
Date - seq(as.Date(2006-09-15), by = '3 months', length = 24)
callSch - data.frame(Price, Type, Date)
callSch$Type - as.character(callSch$Type)

bondparams - list(faceAmount=100, issueDate = as.Date(2004-09-16),
   maturityDate=as.Date(2012-09-16), redemption=100,
   callSch = callSch)
dateparams - list(settlementDays=3, calendar=us, 
   dayCounter = ActualActual, 
   period=Quarterly, 
   businessDayConvention = Unadjusted, 
   terminationDateConvention= Unadjusted)
coupon - c(0.0465)

CallableBond(bondparams, HullWhite, coupon, dateparams)

# ...I get the following error:
# --- SET_VECTOR_ELT() can only be applied to a 'list', not a 'symbol'
---

# Wandering through Internet, I found something similar to my
# issue which has been solved by updating packages.
# I tried the same but no results :(

# Two weeks ago the same code worked properly.
# Any idea about what changed in the meantime?

# Thanks :)





--
View this message in context: 
http://r.789695.n4.nabble.com/RQuantLib-SET-VECTOR-ELT-can-only-be-applied-to-a-list-not-a-symbol-tp4639542.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] RQuantLib: SET_VECTOR_ELT() can only be applied to a 'list', not a 'symbol'

2012-08-08 Thread Cren

Cren wrote
 
 # trying to run the following example code
 # from 'RQuantLib' package...
 
# Obviously, run

require(RQuantLib)

# before executing the example :)



--
View this message in context: 
http://r.789695.n4.nabble.com/RQuantLib-SET-VECTOR-ELT-can-only-be-applied-to-a-list-not-a-symbol-tp4639542p4639544.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] RQuantLib: SET_VECTOR_ELT() can only be applied to a 'list', not a 'symbol'

2012-08-08 Thread Cren

Enrico Schumann-2 wrote
 
 I cannot reproduce this error. I get...
 
   sessionInfo()
 *R version 2.15.1* (2012-06-22)
 
# Thank you for testing, Enrico (Italian? ),
# it seems an updating issue.

# I am trying to update everything possible to the latest
# version because of compatibility.



--
View this message in context: 
http://r.789695.n4.nabble.com/RQuantLib-SET-VECTOR-ELT-can-only-be-applied-to-a-list-not-a-symbol-tp4639542p4639564.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] The best solver for non-smooth functions?

2012-07-19 Thread Cren

Roger Koenker-3 wrote
 
 There are obviously a large variety of non-smooth problems;
 for CVAR problems, if by this you mean conditional value at
 risk portfolio problems, you can use modern interior point 
 linear programming methods.  Further details are here:
 
   http://www.econ.uiuc.edu/~roger/research/risk/risk.html
 
 Roger Koenker
 rkoenker@
 # Hi, Roger.
 
 # Unfortunately that C does not stand for
 # Conditional but Credit... which means that
 # risk measure is obtained via Monte Carlo
 # simulated scenarios in order to quantify the
 # credit loss according to empirical transition
 # matrix. Then I am afraid of every solver finding
 # local maxima (or minima) because of some
 # jump in Credit VaR surface function of
 # portfolio weights :(
 
 
 
 On Jul 18, 2012, at 3:09 PM, Cren wrote:
 
 # Whoops! I have just seen there's a little mistake
 # in the 'sharpe' function, because I had to use
 # 'w' array instead of 'ead' in the cm.CVaR function!
 # This does not change the main features of my,
 # but you should be aware of it
 
 ---
 
 # The function to be minimized
 
 sharpe - function(w) {
  - (t(w) %*% y) / cm.CVaR(M, lgd, ead, N, n, r, rho, alpha, rating)
 } 
 
 # This becomes...
 
 sharpe - function(w) {
  - (t(w) %*% y) / cm.CVaR(M, lgd, w, N, n, r, rho, alpha, rating)
 } 
 
 # ...substituting 'ead' with 'w'.
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/The-best-solver-for-non-smooth-functions-tp4636934p4636936.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@ mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@ mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


--
View this message in context: 
http://r.789695.n4.nabble.com/The-best-solver-for-non-smooth-functions-tp4636934p4637001.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] The best solver for non-smooth functions?

2012-07-19 Thread Cren

Hans W Borchers wrote
 
 The most robust solver for non-smooth functions I know of in R is
 Nelder-Mead 
 in the 'dfoptim' package (that also allows for box constraints).
 
 First throw out the equality constraint by using c(w1, w1, 1-w1-w2) as
 input. 
 This will enlarge the domain a bit, but comes out allright in the end.
 
 sharpe2 - function(w) {
   w - c(w[1], w[2], 1-w[1]-w[2])
   - (t(w) %*% y) / cm.CVaR(M, lgd, w, N, n, r, rho, alpha, rating)
 }
 
 nmkb(c(1/3,1/3), sharpe2, lower=c(0,0), upper=c(1,1))
 ## $par
 ## [1] 0.1425304 0.1425646
 ## $value
 ## [1] -0.03093439
 
 This is still in the domain of definition, and is about the same optimum
 that 
 solnp() finds.
 
 There are some more solvers, especially aimed at non-smooth functions, in
 the 
 making. For low-dimensional problems like this Nelder-Mead is a reasonable 
 choice.

# Thank you, I'll try it :)


--
View this message in context: 
http://r.789695.n4.nabble.com/The-best-solver-for-non-smooth-functions-tp4636934p4637000.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] The best solver for non-smooth functions?

2012-07-19 Thread Cren

Roger Koenker-3 wrote
 
 There are obviously a large variety of non-smooth problems;
 for CVAR problems, if by this you mean conditional value at
 risk portfolio problems, you can use modern interior point 
 linear programming methods.  Further details are here:
 
   http://www.econ.uiuc.edu/~roger/research/risk/risk.html
 
 Roger Koenker
 rkoenker@

# Hi, Roger.

# Unfortunately that C does not stand for
# Conditional but Credit... which means that
# risk measure is obtained via Monte Carlo
# simulated scenarios in order to quantify the
# credit loss according to empirical transition
# matrix. Then I am afraid of every solver finding
# local maxima (or minima) because of some
# jump in Credit VaR surface function of
# portfolio weights :(


--
View this message in context: 
http://r.789695.n4.nabble.com/The-best-solver-for-non-smooth-functions-tp4636934p4637002.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] The best solver for non-smooth functions?

2012-07-18 Thread Cren
# Hi all,

# consider the following code (please, run it:
# it's fully working and requires just few minutes
# to finish):

require(CreditMetrics)
require(clusterGeneration)
install.packages(Rdonlp2, repos= c(http://R-Forge.R-project.org;,
getOption(repos)))
install.packages(Rsolnp2, repos= c(http://R-Forge.R-project.org;,
getOption(repos)))
require(Rdonlp2)
require(Rsolnp)
require(Rsolnp2)

N - 3
n - 10
r - 0.0025
ead - rep(1/3,3)  
rc - c(AAA, AA, A, BBB, BB, B, CCC, D)
lgd - 0.99
rating - c(BB, BB, BBB)  
firmnames - c(firm 1, firm 2, firm 3)
alpha - 0.99

# One year empirical migration matrix from Standard  Poor's website

rc - c(AAA, AA, A, BBB, BB, B, CCC, D)
M - matrix(c(90.81,  8.33,  0.68,  0.06,  0.08,  0.02,  0.01,   0.01,
  0.70, 90.65,  7.79,  0.64,  0.06,  0.13,  0.02,   0.01,
  0.09,  2.27, 91.05,  5.52,  0.74,  0.26,  0.01,   0.06,
  0.02,  0.33,  5.95, 85.93,  5.30,  1.17,  1.12,   0.18,
  0.03,  0.14,  0.67,  7.73, 80.53,  8.84,  1.00,   1.06,
  0.01,  0.11,  0.24,  0.43,  6.48, 83.46,  4.07,   5.20,
  0.21, 0,  0.22,  1.30,  2.38, 11.24, 64.86,  19.79,
  0, 0, 0, 0, 0, 0, 0, 100
)/100, 8, 8, dimnames = list(rc, rc), byrow = TRUE)

# Correlation matrix

rho - rcorrmatrix(N) ; dimnames(rho) = list(firmnames, firmnames)

# Credit Value at Risk

cm.CVaR(M, lgd, ead, N, n, r, rho, alpha, rating)

# Risk neutral yield rates

Y - cm.cs(M, lgd)
y - c(Y[match(rating[1],rc)], Y[match(rating[2],rc)],
Y[match(rating[3],rc)]) ; y

# The function to be minimized

sharpe - function(w) {
  - (t(w) %*% y) / cm.CVaR(M, lgd, ead, N, n, r, rho, alpha, rating)
}

# The linear constraints

constr - function(w) {
  sum(w)
}

# Results' matrix (it's empty by now)

Results - matrix(NA, nrow = 3, ncol = 4)
rownames(Results) - list('donlp2', 'solnp', 'solnp2')
colnames(Results) - list('w_1', 'w_2', 'w_3', 'Sharpe')

# See the differences between different solvers

rho
Results[1,1:3] - round(donlp2(fn = sharpe, par = rep(1/N,N), par.lower =
rep(0,N), par.upper = rep(1,N), A = t(rep(1,N)), lin.lower = 1, lin.upper =
1)$par, 2)
Results[2,1:3] - round(solnp(pars = rep(1/N,N), fun = sharpe, eqfun =
constr, eqB = 1, LB = rep(0,N), UB = rep(1,N))$pars, 2)
Results[3,1:3] - round(solnp2(par = rep(1/N,N), fun = sharpe, eqfun =
constr, eqB = 1, LB = rep(0,N), UB = rep(1,N))$pars, 2)
for(i in 1:3) {
  Results[i,4] - abs(sharpe(Results[i,1:3]))  
}
Results

# In fact the sharpe function I previously defined
# is not smooth because of the cm.CVaR function.
# If you change correlation matrix, ratings or yields
# you see how different solvers produce different
# parameters estimation.

# Then the main issue is: how may I know which is the
# best solver at all to deal with non-smooth functions
# such as this one?

--
View this message in context: 
http://r.789695.n4.nabble.com/The-best-solver-for-non-smooth-functions-tp4636934.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] The best solver for non-smooth functions?

2012-07-18 Thread Cren
# Whoops! I have just seen there's a little mistake
# in the 'sharpe' function, because I had to use
# 'w' array instead of 'ead' in the cm.CVaR function!
# This does not change the main features of my,
# but you should be aware of it

---

# The function to be minimized

sharpe - function(w) {
  - (t(w) %*% y) / cm.CVaR(M, lgd, ead, N, n, r, rho, alpha, rating)
} 

# This becomes...

sharpe - function(w) {
  - (t(w) %*% y) / cm.CVaR(M, lgd, w, N, n, r, rho, alpha, rating)
} 

# ...substituting 'ead' with 'w'.

--
View this message in context: 
http://r.789695.n4.nabble.com/The-best-solver-for-non-smooth-functions-tp4636934p4636936.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Getting objects from quantmod ticker list

2012-07-15 Thread Cren
# Thank you, Michael: it works fine!

--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-objects-from-quantmod-ticker-list-tp4635708p4636440.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Multivariate apply.rolling()

2012-07-15 Thread Cren
# I've read that rollapply, and its wrapper apply.rolling()
# from PerformanceAnalytics package, do not work with multivariate
# time series neither their output can be a multivariate time series.

# Then I was wondering if any other function like those exists, or
# if I need to write my own function to perform multivariate
# time serie rolling analysis.

# Something like this:

# Let 'X' be your multivariate time series:
# output - matrix(NA, ncol = ncol(X), nrow = nrow(X))
# width - 199
# for(i in 1:(nrow(output) - width) {
# data - X[i:(i + width),]   
# output[i,] - function(data)
#}
# rownames(output) - rownames(as.timeSeries(X))

# ...and this should be a (probably not efficient) way to do it.
# Any better idea?

# Thanks,


--
View this message in context: 
http://r.789695.n4.nabble.com/Multivariate-apply-rolling-tp4636442.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Getting objects from quantmod ticker list

2012-07-11 Thread Cren
# One more question, Joshua: let instead of merging tickers
# I would like to put prices from an OHLC object
# in weekly format, then selecting just the close prices.
# What would be a code to do it?
# I guess:

data = new.env()
ticker.list - c('SPY', 'TLT', 'GLD')
getSymbols(ticker.list, env = data)
X - do.call(to.weekly, list(data))

# or something like this, but it doesn't work.
# What could I do? 

--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-objects-from-quantmod-ticker-list-tp4635708p4636162.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Getting objects from quantmod ticker list

2012-07-07 Thread Cren
Hi all,

I would need to put datas downloaded with quantmod into a matrix or a data
frame.

Suppose to start from here:

*require(quantmod)

ticker.list - c('AAA',  'ALTSALES','AMBNS','AMBSL','BAA',  
'EMRATIO',
'FEDFUNDS', 'GASPRICE', 'GS1',  'GS10', 'GS20', 'LNS1410',  'MORTG',
'NAPM', 'NPPTTL',   'OILPRICE', 'PAYEMS',   'TB3MS',
'UNRATE')

series - getSymbols(ticker.list, src= 'FRED')*

May you tell me how could I put each time series into a matrix or a data
frame keeping the dates' alignment?

Thank you 

--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-objects-from-quantmod-ticker-list-tp4635708.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Getting objects from quantmod ticker list

2012-07-07 Thread Cren

Joshua Ulrich wrote
 
 Load the data into an environment, then merge them using do.call():
 
 series.env - new.env()
 getSymbols(ticker.list, src='FRED', env=series.env)
 series - do.call(merge, as.list(series.env))
 
 
Thank you very much, Joshua: this works very well!

Thank you :)


--
View this message in context: 
http://r.789695.n4.nabble.com/Getting-objects-from-quantmod-ticker-list-tp4635708p4635721.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Simultaneous equations

2012-06-08 Thread Cren
Hi all,

I was wondering why I get errors trying to solve this:

*simeq - function(x) {
  f - numeric(length(x))
  f[1] - x[1] * dnorm((log(x[1]/D) + (r + x[2]^2/2) * T)/(x[2] * sqrt(T)))
- D * exp(-r * T) * dnorm((log(x[1]/D) + (r + x[2]^2/2) * T)/(x[2] *
sqrt(T)) - x[2] * sqrt(T))
  f[2] - dnorm((log(x[1]/D) + (r + x[2]^2/2) * T)/(x[2] * sqrt(T))) * x[2]
* x[1]
}
x.start - c(100,0.2)
nleqslv(x.start, simeq)*

or, alternatively, this

*simeq - function(V_0, sigma_v) {
  f - numeric(2)
  f[1] - V_0 * dnorm((log(V_0/D) + (r + sigma_v^2/2) * T)/(sigma_v *
sqrt(T))) - D * exp(-r * T) * dnorm((log(V_0/D) + (r + sigma_v^2/2) *
T)/(sigma_v * sqrt(T)) - sigma_v * sqrt(T))
  f[2] - dnorm((log(V_0/D) + (r + sigma_v^2/2) * T)/(sigma_v * sqrt(T))) *
sigma_v * V_0
}
x.start - c(100,0.2)
nleqslv(x.start, simeq)*

It says the length of function results is different  from that of *x* or
that '*sigma_v*' is missing... what does this mean? I thought I did not need
to initialize *sigma_v*'s value 'cause this is a function's variable...

Thank you

--
View this message in context: 
http://r.789695.n4.nabble.com/Simultaneous-equations-tp2524645p4632788.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Subtracting test string from vectors

2012-06-01 Thread Cren
Hi all,

let I have two text string:

*one - c(ciao,zio,caio,bello)
two - c(caio,zio)*

I would like to obtain a new text string which is* one - two* like this one:

[1] ciao bello

because caio and zio elements have been subtracted from *one*.

What's the most efficient way to obtain this?

Thank you,


--
View this message in context: 
http://r.789695.n4.nabble.com/Subtracting-test-string-from-vectors-tp4632049.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Subtracting test string from vectors

2012-06-01 Thread Cren

Rui Barradas wrote
 
 Hello,
 
 ?setdiff
 setdiff(one, two)
 
Thank you for your help, Rui.

But

* setdiff(one,two)
[1] ciao*

Where's bello?

--
View this message in context: 
http://r.789695.n4.nabble.com/Subtracting-test-string-from-vectors-tp4632049p4632053.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to sum and group data by DATE in data frame

2012-05-17 Thread Cren
Thank you, Michael :)

Michael Weylandt wrote
 
 If that doesn't nail it down, I'll need you to answer the questions I
 asked in my previous email.
Previously I made a mistake with *dput()*, this is the correct output:

 dput(X)
new(timeSeries
, .Data = structure(c(124.3, 124.38, 124.67, 125.19, 124.9, 125.27,
125.5, 
125.58, 125.91, 125.8, 125.83, 126.215, 126.25, 126.25, 124.901, 
124.43, 124.4654, 124.46, 124.68, 124.86, 124.73, 125.22, 125.48, 
125.5601, 125.4091, 125.15, 125.43, 125.481, 125.91, 125.29, 
124.79, 124.77, 124.7, 124.37, 124.56, 124.86, 125.3, 125.59, 
125.95, 125.73, 126.27, 126.26, 127.33, 126.37, 126.46, 126, 
126.06, 126.2662, 126.23, 126.4499, 127.12, 127.48, 127.49, 127.69, 
127.88, 127.88, 124.51, 124.42, 124.92, 125.18, 125.23, 124.81, 
125.07, 124.61, 123.8869, 123.24, 123.3329, 123.6, 123.19, 123.161, 
123.96, 123.58, 123.42, 123.68, 124.19, 123.985, 124.24, 124.61, 
124.6566, 124.18, 123.795, 124.36, 124.32, 124.32, 126.1101, 
126.42, 126.8181, 126.79, 126.675, 126.68, 126.685, 126.725, 
126.65, 126.77, 126.55, 126.63, 126.67, 126.66, 125.8829, 126.05, 
125.97, 125.99, 125.59, 125.21, 125.31, 125.46, 125.39, 125.23, 
124.93, 125.32, 125.46, 125.46, 125.62, 125.34, 125.163, 125.01, 
125.115, 125.67, 126.08, 126.15, 126.33, 126.19, 126.3955, 126.71, 
126.083, 126.083, 125.23, 124.96, 125.595, 125.77, 125.4, 125.38, 
125.54, 126.01, 126.05, 126.01, 125.72, 124.79, 124.05, 124.08, 
123.35, 123.85, 123.75, 123.5, 123.58, 122.9285, 122.14, 122.02, 
121.86, 121.58, 121.79, 121.68, 122.18, 122.105, 122.37, 122.02, 
122.4765, 122.31, 121.99, 121.8401, 121.85, 122.17, 122.27, 122.26, 
122.08, 122.02, 121.979, 121.979, 119.74, 119.55, 118.95, 119.12, 
119.14, 118.91, 119.0201, 119.235, 118.93, 119.51, 119.51, 120.04, 
119.63, 119.661, 119.77, 119.78, 118.89, 118.85, 118.9, 119.2671, 
119.73, 119.8, 119.52, 119.43, 119.16, 119.28, 119.19, 119.19, 
117.43, 117.18, 117.3, 116.87, 117.07, 117.0565, 117.4497, 117.47, 
117.07, 116.856, 116.91, 117.075, 116.6, 116.56, 117.09, 117.361, 
117.35, 117.2787, 116.72, 116.76, 116.34, 116.34, 116.34, 119.88, 
119.98, 119.8095, 119.995, 119.88, 119.685, 119.48, 119.845, 
119.505, 119.65, 119.36, 119.02, 119.73, 119.71, 120.44, 120.65, 
120.45, 120.53, 120.41, 120.67, 120.399, 120.39, 119.91, 120.069, 
120.18, 120.37, 120.05, 120.05, 123.9711, 124.01, 124.47, 124.14, 
124.14, 124.12, 124.14, 123.94, 123.86, 124, 124.07, 124.33, 
125.04, 124.99, 125.47, 125.39, 124.91, 124.5802, 124.88, 124.89, 
124.48, 124.88, 125.335, 125.12, 125.07, 125.25, 124.96, 124.97, 
126.02, 126.41, 126.19, 125.93, 125.5199, 125.575, 125.6702, 
125.471, 125.506, 125.41, 125.14, 125.18, 124.86, 124.86, 126.63, 
127.01, 126.881, 126.86, 126.81, 126.86, 127.05, 126.945, 126.2946, 
126.1511, 126.28, 125.54, 126.24, 126.22, 125.99, 126.41, 126.12, 
126.05, 126.17, 126.13, 126.14, 126.43, 126.26, 126.35, 126.89, 
126.645, 126.26, 126.26, 125.5, 125.12, 125.49, 125.86, 125.96, 
126.28, 126.37, 126.35, 126.115, 126.1, 125.83, 126.42, 126.73, 
126.73, 125.79, 125.32, 125.4, 124.98, 125.0601, 125, 124.84, 
124.5, 124.6246, 124.56, 124.29, 124.78, 123.98, 123.95, 125.13, 
125.24, 125.48, 125.84, 125.73, 125.76, 125.87, 126.02, 125.9, 
126.09, 126.19, 126.21, 126.05, 126.05, 124.208, 123.96, 124.04, 
123.9, 123.4, 123.48, 123.5046, 123.55, 123.5911, 123.59, 123.71, 
123.825, 124.19, 124.21, 125.38, 125.0199, 124.64, 124.64, 124.85, 
124.675, 124.79, 124.67, 124.79, 124.53, 123.86, 123.1, 123.05, 
123.05, 122.42, 122.25, 121.81, 121.77, 121.66, 121.94, 122.1484, 
122.5, 122.0654, 122.07, 121.67, 121.96, 121.71, 121.74, 123.06, 
122.57, 122.21, 122.55, 122.31, 122.71, 122.47, 122.4773, 122.405, 
122.31, 122.18, 122.37, 122.18, 122.185, 122.44, 122.68, 122.69, 
122.51, 121.9, 121.74, 121.6, 121.78, 121.5999, 121.46, 121.67, 
121.57, 121.59, 121.59, 122.05, 121.892, 121.47, 121.28, 120.85, 
121.09, 121.15, 121.02, 121.24, 121.02, 121.07, 120.21, 120.32, 
120.29, 122.99, 123.3, 123.35, 123.47, 123.4254, 123.469, 123.54, 
123.72, 123.7, 123.72, 123.9, 123.97, 123.92, 123.93, 123.26, 
123.49, 123.31, 123.13, 123.2, 122.85, 123.34, 123.34, 123.59, 
123.57, 123.73, 124.03, 124.17, 124.17, 124.98, 124.97, 124.78, 
124.8, 124.88, 125.25, 125.22, 125.3, 125.201, 125.3289, 125.1, 
125.345, 125.4, 125.27, 125.66, 125.68, 125.73, 125.946, 126.04, 
126.11, 126.2, 126.08, 126.11, 126.02, 126.05, 126.005, 126.41, 
126.39, 126.77, 126.78, 126.39, 126.57, 126.55, 126.635, 126.58, 
126.55, 126.72, 126.62, 126.7, 126.65, 126.49, 126.49, 125.74, 
125.4, 125.39, 125.1, 125.05, 125.08, 124.94, 125.14, 125.29, 
125.13, 124.99, 124.78, 124.88, 124.83, 125.42, 125.6991, 125.83, 
125.64, 125.9505, 125.8001, 125.83, 125.8077, 125.88, 125.89, 
125.86, 126, 126.12, 126.12, 126.1685, 126.08, 126.11, 126.22, 
126.03, 126, 126.04, 126, 126.04, 125.78, 125.839, 125.94, 125.5, 
125.5, 127.95, 128.19, 128.24, 128.18, 127.955, 127.937, 127.52, 
127.56, 127.73, 127.85, 128.04, 127.78, 127.49, 127.495, 127.36, 
126.9246, 

Re: [R] Correlation Matrix

2012-05-17 Thread Cren
Hi,

unless you're dealing with heteroskedastic datas, the command *cor(x)* will
be enough, where *x* is your data matrix; in this function you can easily
select the method which has to be used: Pearson's, Kendall's or Spearman's
correlation.

--
View this message in context: 
http://r.789695.n4.nabble.com/Correlation-Matrix-tp4630389p4630392.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to sum and group data by DATE in data frame

2012-05-16 Thread Cren

Michael Weylandt wrote
 
 Can you provide a reproducible example? 
 
Of course, Michael.

Consider the following time series:


11/2/2011 14:30 123.53
11/2/2011 15:00 123.78
11/2/2011 15:30 124.24
11/2/2011 16:00 124.2
11/2/2011 16:30 124.07
11/2/2011 17:00 123.91
11/2/2011 17:30 123.44
11/2/2011 18:00 123.0616
11/2/2011 18:30 123.06
11/2/2011 19:00 123.13
11/2/2011 19:30 123.745
11/2/2011 20:00 123.96
11/2/2011 20:30 123.99
11/2/2011 21:00 123.99
11/3/2011 14:30 124.3
11/3/2011 15:00 124.38
11/3/2011 15:30 124.67
11/3/2011 16:00 125.19
11/3/2011 16:30 124.9
11/3/2011 17:00 125.27
11/3/2011 17:30 125.5
11/3/2011 18:00 125.58
11/3/2011 18:30 125.91
11/3/2011 19:00 125.8
11/3/2011 19:30 125.83
11/3/2011 20:00 126.215
11/3/2011 20:30 126.25
11/3/2011 21:00 126.25
11/4/2011 14:30 124.901
11/4/2011 15:00 124.43
11/4/2011 15:30 124.4654
11/4/2011 16:00 124.46
11/4/2011 16:30 124.68
11/4/2011 17:00 124.86
11/4/2011 17:30 124.73
11/4/2011 18:00 125.22
11/4/2011 18:30 125.48
11/4/2011 19:00 125.5601
11/4/2011 19:30 125.4091
11/4/2011 20:00 125.15
11/4/2011 20:30 125.43
11/4/2011 21:00 125.481
11/7/2011 15:30 125.91
11/7/2011 16:00 125.29
11/7/2011 16:30 124.79
11/7/2011 17:00 124.77
11/7/2011 17:30 124.7
11/7/2011 18:00 124.37
11/7/2011 18:30 124.56
11/7/2011 19:00 124.86
11/7/2011 19:30 125.3
11/7/2011 20:00 125.59
11/7/2011 20:30 125.95
11/7/2011 21:00 125.73
11/7/2011 21:30 126.27
11/7/2011 22:00 126.26
11/8/2011 15:30 127.33
11/8/2011 16:00 126.37
11/8/2011 16:30 126.46
11/8/2011 17:00 126
11/8/2011 17:30 126.06
11/8/2011 18:00 126.2662
11/8/2011 18:30 126.23
11/8/2011 19:00 126.4499
11/8/2011 19:30 127.12
11/8/2011 20:00 127.48
11/8/2011 20:30 127.49
11/8/2011 21:00 127.69
11/8/2011 21:30 127.88
11/8/2011 22:00 127.88
11/9/2011 15:30 124.51
11/9/2011 16:00 124.42
11/9/2011 16:30 124.92
11/9/2011 17:00 125.18
11/9/2011 17:30 125.23
11/9/2011 18:00 124.81
11/9/2011 18:30 125.07
11/9/2011 19:00 124.61
11/9/2011 19:30 123.8869
11/9/2011 20:00 123.24
11/9/2011 20:30 123.3329
11/9/2011 21:00 123.6
11/9/2011 21:30 123.19
11/9/2011 22:00 123.161

The rownames are datas plus hour, the data column is the time series' value.

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-sum-and-group-data-by-DATE-in-data-frame-tp903708p4630228.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to sum and group data by DATE in data frame

2012-05-15 Thread Cren
Hello, 

I have a time series with intraday datas, sampled every 30'; I would need to
aggregate them in this way: summing up all datas within a day.

I tried to use *aggregate(...)* function to get my goal, but it aggregates
in wrong way (I did not understand how so far); what I need is like
*sum(...)* function applied to datas within the same day.

Thank you :)

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-sum-and-group-data-by-DATE-in-data-frame-tp903708p4630119.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to sum and group data by DATE in data frame

2012-05-15 Thread Cren
Thank you for your help, Michael.

I used *aggregate(x, by = timeSequence(by = day), FUN = sum)* but the
results is very different from *sum(x[1:13])*, where 13 is the number of
daily observations I've sampled.

Michael Weylandt wrote
 
 How are you using aggregate()? It seems to sum for me...
 
 z - zoo(1:50, seq.POSIXt(from = Sys.time(), by = 30 min, length.out =
 50))
 
 aggregate(z, as.Date(time(z)), sum)
 
 Best,
 Michael
 
 On Tue, May 15, 2012 at 11:52 AM, Cren lt;oscar.soppelsa@gt; wrote:
 Hello,

 I have a time series with intraday datas, sampled every 30'; I would need
 to
 aggregate them in this way: summing up all datas within a day.

 I tried to use *aggregate(...)* function to get my goal, but it
 aggregates
 in wrong way (I did not understand how so far); what I need is like
 *sum(...)* function applied to datas within the same day.

 Thank you :)

 --
 View this message in context:
 http://r.789695.n4.nabble.com/How-to-sum-and-group-data-by-DATE-in-data-frame-tp903708p4630119.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@ mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@ mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-sum-and-group-data-by-DATE-in-data-frame-tp903708p4630139.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R i386 2.15.0 'gogarch' package issue

2012-05-14 Thread Cren
Hi all,

I've just downloaded and installed the latest R 32-bit version plus RExcel
and R Commander.
I'm having several problems in loading gogarch package:

The command *library(gogarch, pos=4)* returns *ERROR: package/namespace load
failed for 'gogarch'*
The command *require(gogarch)* returns *Error : Function found when
exporting methods from the namespace 'gogarch' which is not S4 generic:
'print'*

How may I solve it?

Thank you!


--
View this message in context: 
http://r.789695.n4.nabble.com/R-i386-2-15-0-gogarch-package-issue-tp4629888.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R i386 2.15.0 'gogarch' package issue

2012-05-14 Thread Cren
If I use gogarch_0.7-1 the command *require(gogarch)* returns the following
error: *Error in get(.packageName, where) : cannot allocate memoby block
of size 3.2 Gb*

--
View this message in context: 
http://r.789695.n4.nabble.com/R-i386-2-15-0-gogarch-package-issue-tp4629888p4629889.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R i386 2.15.0 'gogarch' package issue

2012-05-14 Thread Cren
Ok, solved.

If anyone had the same problem, just install the last gogarch pacakge (vers.
0.7-1) and restart R + R Commander after the package installation.

When you've restarted it, the command *require(gogarch)* should load fastICA
package in the end and it will work ;)

--
View this message in context: 
http://r.789695.n4.nabble.com/R-i386-2-15-0-gogarch-package-issue-tp4629888p4629890.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re : R i386 2.15.0 'gogarch' package issue

2012-05-14 Thread Cren

Pascal Oettli-2 wrote
 
 Hello,
 
 Probably you should try:
 update.packages(checkBuilt=TRUE)
 
 install.packages('gogarch', dependencies=TRUE)
 
 Best Regards,
 Pascal
 
Dear Pascal Oettli-2,

thank you for your suggestment; I was not aware of that command and it will
be very useful when new release of R will be available ;)

--
View this message in context: 
http://r.789695.n4.nabble.com/R-i386-2-15-0-gogarch-package-issue-tp4629888p4629928.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Hi! Help using FitARMA package in RExcel

2011-05-17 Thread Cren
Hi all :)

Before posting, I used the search function to find a solution, but I
wasn't lucky.

I'm using RExcel; I've read several examples which explain how to call in
RExcel an R function via =RApply(...) but I don't understand how may I
include in the function several numeric arguments.

Take this example: I want to use the following R function from FitARMA
package:

FitARMA(z, order = c(0, 0, 0), demean = TRUE, MeanMLEQ = FALSE, pApprox =
30, MaxLag = 30)

What's the right syntax? How may I get the ARMA coefficients and/or the t+1
ARMA forecast in RExcel?

Thank you very much!

--
View this message in context: 
http://r.789695.n4.nabble.com/Hi-Help-using-FitARMA-package-in-RExcel-tp3528577p3528577.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.