[R] Optimization help

2012-07-30 Thread Megh Dal
Hi, I have following optimization problem: Min: x1 + x2 +...+ x7 subject to: x1 + x2 = 80 x2 + x3 = 65 x3 + x4 = 40 all xi are ***positive integer***. Can somebody help me in this optimization problem? Thanks for your help __ R-help@r-project.org

[R] Applying ifelse() on different functions

2011-07-30 Thread Megh Dal
Dear all, I am looking for some procedure to apply 'ifelse' condition on function. I have created an alternative to lapply() function with exactly same set of arguments named lapply1(), however with different internal codes. Therefore I want something like, if (some condition) then call

[R] Suppressing messages while executing function

2011-07-27 Thread Megh Dal
Dear all, while executing some function, there are some custom messages popping up onto the R console and I do not want to see them. While looking into the corresponding codes of those function, I see that those are coming from message() function. Is there any way to stop those messages coming

[R] Achieving 'reverse-Vech' of a matrix

2011-07-23 Thread Megh Dal
Let say i have a square matrix and applied the 'vech' operator to stack the lower triangular elements into a vector: Mat - matrix(1:25, 5) Mat      [,1] [,2] [,3] [,4] [,5] [1,]    1    6   11   16   21 [2,]    2    7   12   17   22 [3,]    3    8   13   18   23 [4,]    4    9   14   19   24

[R] Seeking help on permutation

2011-07-22 Thread Megh Dal
Let say, I have a character vector of arbitrary length: Vector - c(a, b, c) Using that vector I would like to create a matrix (with number of columns as 2) with all pairwise combinations of those elements, like: Vector - c(a, b, c) Mat     - rbind(c(a, b), c(a, c), c(b, c)); Mat  # number of

[R] String manipulation

2011-06-26 Thread Megh Dal
Dear all, I have following kind of character vector: Vec - c(344426, dwjjsgcj, 123sgdc, aagha123, sdh343asgh, 123jhd51) Now I want to split each element of this vector according to numeric and string element. For example in the 1st element of that vector, there is no string element. Therefore

[R] 3D plot with it's quadratic approximation superimposed in same plot

2011-05-23 Thread Megh Dal
Dear all, I would like to draw a 3D plot as shown here http://en.wikipedia.org/wiki/File:NaturalLogarithmAll.png, for this function f = exp[ 1 - x^2 - y^2] (this function is some arbitrary!). I am aware of different 3D plotting system in R, however it would be great if I can get that kind of

[R] Custom Zero equivalent in R

2011-05-06 Thread Megh Dal
Hi all, I am to find some way on how I can tell R to use this small number 10^-20 as zero by default. This means if any number is below this then that should be treated as negative, or if I divide something by any number less than that (in absolute term) then, Inf will be displayed etc. I have

[R] String manipulation

2011-02-13 Thread Megh Dal
Please consider following string: MyString - ABCFR34564IJVEOJC3434 Here you see that, there are 4 groups in above string. 1st and 3rd groups are for english letters and 2nd and 4th for numeric. Given a string, how can I separate out those 4 groups? Thanks for your time [[alternative

Re: [R] String manipulation

2011-02-13 Thread Megh Dal
IJVEOJC 3434. 36453 Can you please tell me how can I modify that? Thanks, On Sun, Feb 13, 2011 at 11:10 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, Feb 13, 2011 at 10:27 AM, Megh Dal megh700...@gmail.com wrote: Please consider following string: MyString

[R] Help need to define method of an s4 class

2011-02-01 Thread Megh Dal
I need some help in defining a print method for my new S4 class definition. So fer I have worked like this: setClass(MyClass, sealed=F, representation(slot1 = list,#create a new class slot2= vector, slot3 = vector, slot4 = vector))

[R] Comparing lengths of different vectors simultaneously

2011-01-31 Thread Megh Dal
I am looking for an elegant way how I can test the equality of lengths of multiple vectors. For example, this is working fine: length(rnorm(4)) == length(rnorm(5)) [1] FALSE However this is not: length(rnorm(4)) == length(rnorm(5)) == length(rnorm(6)) Error: unexpected '==' in

[R] Downloading data from internet

2011-01-24 Thread Megh Dal
Dear all, I need to download an excel file from net, on which I have address like http://www.2shared.com/file/MMSMWv4B/MyData.html. Can I somehow directly download this file into my R workbook? Thanks, [[alternative HTML version deleted]] __

[R] Where to find rcompgen package?

2010-12-25 Thread Megh Dal
Dear all, can somebody point me from where to download rcompgen package? CRAN does not seem to hold that. Installing this package through install.packages() tells this package is not available. Thanks [[alternative HTML version deleted]] __

[R] Extracting elements of a particular slot from S4 object

2010-11-06 Thread Megh Dal
Hi there, can anyone tell me how to extract to values of a particular slot for some S4 object? Let take following example: library(fOptions) val -GBSOption(TypeFlag = c, S = 60, X = 65, Time = 1/4, r = 0.08, b = 0.08, sigma = 0.30) val Title: Black Scholes Option Valuation Call:

[R] Recursive algorithm

2010-11-01 Thread Megh Dal
Dear friend, I have to construct some recursive algorithm for which I used some for loop like: res - vector(length=1) res[1] = 0 for (i in 2:(1+1)) res[i] - res[i-1]*some function I have noticed that this is taking too much time. Is there any way to speed up things? Thanks,

[R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
Dear all, I have following 2 zoo objects. However when I try to merge those 2 objects into one, nothing is coming as intended. Please see below the objects as well as the merged object: dat11 V2 V3 V4 V5 2010-10-15 13:43:54 73.8 73.8 73.8 73.8 2010-10-15 13:44:15

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
: [R] Problem with merging two zoo objects To: Megh Dal megh700...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Saturday, October 16, 2010, 12:11 AM On Fri, Oct 15, 2010 at 2:20 PM, Megh Dal megh700...@yahoo.com wrote: Dear all, I have following 2 zoo objects. However when I try to merge

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
matter? Thanks, --- On Sat, 10/16/10, Megh Dal megh700...@yahoo.com wrote: From: Megh Dal megh700...@yahoo.com Subject: Re: [R] Problem with merging two zoo objects To: Gabor Grothendieck ggrothendi...@gmail.com Cc: r-help@r-project.org Date: Saturday, October 16, 2010, 7:20 AM I dont know

Re: [R] Problem with merging two zoo objects

2010-10-15 Thread Megh Dal
I dont know whether I am missing something or not: head(read.zoo(file=f:/dat1.txt, header=T, sep=,, format = %m/%d/%Y %H:%M:%S), tz=GMT) data.open data.high data.low data.close 2010-10-15 73.7 73.7 73.7 73.7 2010-10-15 73.8 73.8 73.8 73.8

[R] Query on save.image()

2010-10-14 Thread Megh Dal
Can anyone please tell me how can use save.image() function if it is placed within a function (i.e. some level up from the base level environment)? Here I experimented with following codes: #rm(list=ls()) fn - function() { x - rnorm(5) save.image(f:/dat.RData) } fn() However I see

Re: [R] Query on save.image()

2010-10-14 Thread Megh Dal
the same against envir. By putting so, what I am going to tell R? Thanks, --- On Thu, 10/14/10, Joshua Wiley jwiley.ps...@gmail.com wrote: From: Joshua Wiley jwiley.ps...@gmail.com Subject: Re: [R] Query on save.image() To: Megh Dal megh700...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Thursday

[R] Formating a matrix in a exotic way

2010-09-19 Thread Megh Dal
Suppose I have following arbitrary matrix: set.seed(1) mat - matrix(rnorm(6), 3, 2) mat [,1] [,2] [1,] -0.6264538 1.5952808 [2,] 0.1836433 0.3295078 [3,] -0.8356286 -0.8204684 Now I want to make a simple object like (character type):

[R] Splitting a matrix

2010-09-16 Thread Megh Dal
Hi, I was trying to split the following matrix dat: set.seed(1) dat - matrix(rnorm(4*16), 4, 16) dat [,1] [,2] [,3][,4][,5][,6] [,7] [,8][,9] [,10] [,11] [1,] -0.6264538 0.3295078 0.5757814 -0.62124058 -0.01619026

[R] Spliting a text

2010-08-04 Thread Megh Dal
Hi, I want to split a text to seperate numerical and non-numerical portions of that. For example suppose I have a text abc 3456 and I want to split in 2 parts like abc 3456. Is there any function to do that? Thanks, __ R-help@r-project.org mailing

[R] How to understand whether a class is a S3 class?

2010-08-01 Thread Megh Dal
Hi, is there any way to say: this class 'x' is a S3 class? For example what is the type of class data.frame? Is it a S3 class or S4? How can I get a complete list of all S3 classes currently available? Thanks, __ R-help@r-project.org mailing list

[R] Having problem to define a subclass, please help me

2010-07-30 Thread Megh Dal
Here I am having problem to define a subclass, specially if I define that subclass after defining initialize() method for its superclass. Here is my code: setClass(a, representation=list(x=numeric, y=numeric), prototype=list(x=rnorm(10), y=rnorm(10))) [1] a setMethod(initialize, a,

[R] Fw: Having problem to define a subclass, please help me

2010-07-30 Thread Megh Dal
understanding, all defined law for super-class should be inherited by it's sub-class, therefore no need to define again. I would be really grateful if someone clarify those. Thanks --- On Fri, 7/30/10, Megh Dal megh700...@yahoo.com wrote: From: Megh Dal megh700...@yahoo.com Subject: Having problem

[R] Objects within environment

2010-07-21 Thread Megh Dal
Hi all, I have following environments loaded with my current R session: search() [1] .GlobalEnvpackage:stats package:graphics package:grDevices [5] package:utils package:datasets package:methods Autoloads [9] package:base How can I find the objects under a

Re: [R] Objects within environment

2010-07-21 Thread Megh Dal
: [R] Objects within environment To: Megh Dal megh700...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Wednesday, July 21, 2010, 4:48 PM On 21/07/2010 5:57 AM, Megh Dal wrote: Hi all, I have following environments loaded with my current R session: search() [1] .GlobalEnv

Re: [R] Objects within environment

2010-07-21 Thread Megh Dal
Thanks Duncan, I understood. Your explanation is really great. Thank you so much for your time. --- On Wed, 7/21/10, Duncan Murdoch murdoch.dun...@gmail.com wrote: From: Duncan Murdoch murdoch.dun...@gmail.com Subject: Re: [R] Objects within environment To: Megh Dal megh700...@yahoo.com Cc

[R] Downloading data fron web

2010-07-20 Thread Megh Dal
Dear all, I need to download some data from this webpage: http://markets.ft.com/ft/markets/researchArchive.asp Notable thing here is that there are some fields to be selected to get the desired data. Is there any R facility to do this directly? Obviously I can do it manually and then just

[R] Split a time series

2010-07-14 Thread Megh Dal
Hi all, can somebody help me to split a time series (zoo) object on monthwise. For example, suppose I have following time series object: library(zoo) dat1 - zooreg(rnorm(300), start=as.Date(2009-01-01), frequency=1) From dat1, I want to create a list-object dat2 like: dat2[[1]] - all

[R] Need help on index for time series object

2010-07-13 Thread Megh Dal
Dear all, Please forgive me if there is a duplicate post; my previous mail perhaps didnt reach the list... Let say I have following time series library(zoo) dat1 - zooreg(rnorm(10), start=as.Date(2010-01-01), frequency=1) dat1[c(3, 7,8)] = NA dat1 2010-01-01 2010-01-02 2010-01-03

[R] A Statistics related question

2010-06-20 Thread Megh Dal
Hi all, good morning, My question is not really R related rather a practical problem and wondering if stat-gurus here can show some light how that can be solved with some statistical/mathematical tool. I have some 10 items on which 10,000 viewers put their views based on some 12 attributes

Re: [R] Handling character string

2010-06-12 Thread Megh Dal
/12/10, Erik Iverson er...@ccbr.umn.edu wrote: From: Erik Iverson er...@ccbr.umn.edu Subject: Re: [R] Handling character string To: Megh Dal megh700...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Saturday, June 12, 2010, 2:36 AM Megh Dal wrote: Dear all, Is there any R function to say these 2

Re: [R] Handling character string

2010-06-12 Thread Megh Dal
...@gmail.com Subject: Re: [R] Handling character string To: Megh Dal megh700...@yahoo.com Cc: Erik Iverson er...@ccbr.umn.edu, r-h...@stat.math.ethz.ch Date: Saturday, June 12, 2010, 10:18 PM This is probably what you want: sub(^[[:space:]]*, ,     Now is the time) [1] Now is the time You need

[R] Handling character string

2010-06-11 Thread Megh Dal
Dear all, Is there any R function to say these 2 character strings temp  and temp are actually same? If I type following code R says there are indeed different : temp  == temp[1] FALSE Is there any way out? [[alternative HTML version deleted]]

[R] Help needed on switch function

2010-06-09 Thread Megh Dal
Hi all, Here I am trying to implement the switch() function to choose value of a variable depending on the value of an input variable :   temp1 - 1   temp1.name - switch(temp1,   1 == aa,   2 == bb,    

[R] Seeking help on Vectorize()

2010-06-02 Thread Megh Dal
Dear falks, here I have written following function :   fn - Vectorize(function(x = 1:3, y = 3:6) {     x - matrix(x, nrow=1)     y - matrix(y, ncol=1)     dat - apply(x, 2, function(xx) {   apply(y, 1, function(yy) {  

[R] [RGL] Need help to modify current plot

2010-05-18 Thread Megh Dal
Dear folks, I have created a plot on RGL device :   x = 1:6 y = seq(-12, 5, by=1) z = matrix(0, length(y), length(x)) z[13,3] = 1; z[13,4] = 1.011765 surface3d(x, y, t(z), col=rainbow(1000)) grid3d(c(x-, y-, z))   Now I want to draw 2 lines along x=3 x=4, over the surface (with different

Re: [R] [RGL] Need help to modify current plot

2010-05-18 Thread Megh Dal
Murdoch murdoch.dun...@gmail.com Subject: Re: [R] [RGL] Need help to modify current plot To: Megh Dal megh700...@yahoo.com Cc: r-h...@stat.math.ethz.ch Date: Tuesday, May 18, 2010, 3:51 PM Megh Dal wrote: Dear folks, I have created a plot on RGL device :   x = 1:6 y = seq(-12, 5, by=1) z

[R] Protecting elements within a function

2010-05-06 Thread Megh Dal
Hi all, previously I submitted this thread through Nabble which seems fail therefore sending it again suppose I have written following function :  fn = function(x) return(x+x^2)  fn  function(x) return(x+x^2)  Here you see, if I type only the function name all inside information of this

[R] Defining a list

2008-10-15 Thread Megh Dal
Can anyone please tell me how to define a list. Suppose I want to define a list object result with length n then want to fill each place of result with different objects. For e.g. i=1 result[1] = rnorm(1) i=2 result[2] = rnorm(2) ... i=n result[n] = rnorm(n) What would

[R] Extracting subset of a vector

2008-10-11 Thread Megh Dal
I have 2 vecros : x-c(100,96,88,100,100,96,80,68,92,96,88,92,68,84,84,88,72,88,72,88) x1 = sample(x, 5, replace=FALSE) Now i want to get remaining values of vector x those are not member of vector x1. Can anyone please tell me how to do that? __

Re: [R] Extracting subset of a vector

2008-10-11 Thread Megh Dal
PROTECTED] Cc: [EMAIL PROTECTED] Date: Sunday, October 12, 2008, 1:06 AM Hi Megh, Try this: x-c(100,96,88,100,100,96,80,68,92,96,88,92,68,84,84,88,72,88,72,88) x1 = sample(x, 5, replace=FALSE) x[ ! x %in% x1] HTH, Jorge On Sat, Oct 11, 2008 at 3:25 PM, Megh Dal [EMAIL PROTECTED

[R] Error in Q-Q plot

2008-10-06 Thread Megh Dal
Hi, I am trying to draw a Q-Q plot, however got following error. library(sn) library(car) dat1 = rst(1000, 0, 1, 0, 2) qq.plot(dat1, st, 0, 1, 0, 9) Error in plot.window(...) : invalid value specified for graphical parameter las Can anyone please tell me why this error is coming?

[R] Adding plane in a 3D scatterplot

2008-10-02 Thread Megh Dal
I have drawn a 3D scatter plot : library(mnormt) library(scatterplot3d) dat = cbind(rmnorm(3, rep(0,2), diag(2)), 1:3) scatterplot3d(dat) Now I want to do 2 things : 1 : In the Z-axis (i.e. height), I want to see only numbers 1,2,3, etc NOT, 1,1.5,2,2.5. 2. I want to add two

Re: [R] Adding plane in a 3D scatterplot

2008-10-02 Thread Megh Dal
) --- On Thu, 10/2/08, Uwe Ligges [EMAIL PROTECTED] wrote: From: Uwe Ligges [EMAIL PROTECTED] Subject: Re: [R] Adding plane in a 3D scatterplot To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Thursday, October 2, 2008, 11:38 PM Megh Dal wrote: I have drawn a 3D scatter plot : library

[R] error in fBasics package

2008-09-30 Thread Megh Dal
When I try to load fBasics package, I get following error/warning : library(fBasics) Loading required package: fImport Loading required package: fSeries Loading required package: fBasics Loading required package: fImport Loading required package: fSeries Loading required package: fBasics Loading

[R] Generating a valid covariance matrix

2008-09-26 Thread Megh Dal
I want to generate a valid variance-covariance matrix. One way could be to generate some random sample from multivariate normal distribution and then calculate cov. matrix. Another way could be to sample from wishart distribution itself. However both cases need a valid i.e. PD covariance

[R] Symmetric matrix

2008-09-21 Thread Megh Dal
I have following matrix : a = matrix(rnorm(36), 6) Now I want to replace the lower-triangular elements with it's upper-triangular elements. That is I want to make a symmetric matrix from a. I have tried with lower.tri() and upper.tri() function, but got desired result. Can anyone please tell

Re: [R] Loop on vector name

2008-09-18 Thread Megh Dal
hope it helps. Best, Dimitris Megh Dal wrote: [My previous message rejected, therefore I am sending same one with some modification] I have 3 vectors with object name : dat1, dat2, dat3 Now I want to create a loop, like : for (i in 1:3) { cat(sd(dati

Re: [R] Loop on vector name

2008-09-18 Thread Megh Dal
) lis output - sapply(lis, sd) print(output) print(str(output)) On Fri, Sep 19, 2008 at 1:44 AM, Megh Dal wrote: Thanks for this mail. It runs perfectly, but now I stuck on how to convert the result in a vector format for further matrix-compputation. e.g. How to convert sapply

Re: [R] Compiling date

2008-09-10 Thread Megh Dal
] Compiling date To: David Scott [EMAIL PROTECTED] Cc: Dr Eberhard W Lisse [EMAIL PROTECTED], Megh Dal [EMAIL PROTECTED], [EMAIL PROTECTED] Date: Tuesday, September 9, 2008, 11:37 PM Is this Month-Day or Day-Month or a mixture of both? I still think using the Format - Cell - Date will work much

[R] How to find where is the space in data

2008-09-10 Thread Megh Dal
I have following 1975 01 7711.16 Here I need to identify where the space is there and then concatenate rest of the digits without space, i.e. I want to have 1975017711.16. Is there any R function? Regards, __ R-help@r-project.org mailing list

[R] Woring message in as.yearmon()

2008-09-10 Thread Megh Dal
I have following dataset: res [,1] [,2] [,3] [1,] 19464 1.27 [2,] 19465 1.27 [3,] 19466 1.27 [4,] 19467 1.27 [5,] 19468 1.52 [6,] 19469 1.52 [7,] 1946 10 1.52 [8,] 1946 11 1.52 [9,] 1946 12 1.62 [10,] 19471 1.62 [11,] 19472 1.62 [12,] 1947

[R] Compiling date

2008-09-09 Thread Megh Dal
Hi, I have following kind of dataset (all are dates) in my Excel sheet. 09/08/08 09/05/08 09/04/08 09/02/08 09/01/08 29/08/2008 28/08/2008 27/08/2008 26/08/2008 25/08/2008 22/08/2008 21/08/2008 20/08/2008 18/08/2008 14/08/2008 13/08/2008 08/12/08 08/11/08 08/08/08 08/07/08 However I want to use

[R] Interactive plot

2008-07-24 Thread Megh Dal
I have created following interactive plot : library(TeachingDemos) plott = function(x) { return(hist(rnorm(as.integer(1000, 10, x)), xlab=NA)) } tkexamp(plott, list(x=list('slider',from=1,to=40, resolution=0.1, init=2)), plotloc='top') Here everything works fine, but the problaem is

Re: [R] Interactive plot

2008-07-24 Thread Megh Dal
: Thursday, July 24, 2008, 5:42 PM On 7/24/2008 7:34 AM, Megh Dal wrote: I have created following interactive plot : library(TeachingDemos) plott = function(x) { return(hist(rnorm(as.integer(1000, 10, x)), xlab=NA)) } tkexamp(plott, list(x=list('slider',from=1,to=40

[R] scatter plot using ggplot

2008-07-22 Thread Megh Dal
I used ggplot to create a scatter plot : library(ggplot) library(mnormt) Sigma = matrix(c(1, 0.6, 0.6, 1), 2, 2) x = rmnorm(20, c(0,0), Sigma) xx = x[order(x[,1]),] y = xx[,1] z = xx[,2] qplot(z, y, type=point, main=x-y plot, xlab=x, col=blue) However I want following: 1. Plot color must be

[R] How to extract folowing data?

2008-07-14 Thread Megh Dal
Hi, following data is taken from http://www.economagic.com/em-cgi/data.exe/var/west-texas-crude-long. Problem with this data is when you copy it from this site you would get something like that : 1946 063331.27 1946 079991.27 1946 087771.52 1946 096661.52 They should be interpret in

Re: [R] Error in defining function

2008-07-07 Thread Megh Dal
, sapply(tolower(funs), f, simplify = FALSE)) On Sun, Jul 6, 2008 at 10:43 PM, Megh Dal [EMAIL PROTECTED] wrote: I made some changes and also incorporated your advice : library(zoo) Z.index - as.Date(sample(12450:15500, 3000)) Z.data - matrix(rnorm(300), ncol = 1) data1 - zoo

[R] Error in defining function

2008-07-06 Thread Megh Dal
Can anyone please tell me why I am getting this error? library(zoo) Z.index - as.Date(sample(12450:15500, 3000)) Z.data - matrix(rnorm(300), ncol = 1) data1 - zoo(Z.data, Z.index) fnc = function(data1) { selection2 = select.list(c(Mean), multiple = F) Mean = function(dataa)

Re: [R] Error in defining function

2008-07-06 Thread Megh Dal
in defining function To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Monday, July 7, 2008, 1:23 AM On Sun, Jul 6, 2008 at 3:19 PM, Megh Dal [EMAIL PROTECTED] wrote: Can anyone please tell me why I am getting this error? library(zoo) Z.index - as.Date(sample(12450:15500, 3000)) Z.data

[R] Calculating quarterly statistics for time series object

2008-06-29 Thread Megh Dal
I have time series observation on daily frequencies : library(zoo) SD=1 date1 = seq(as.Date(01/01/01, format = %m/%d/%y), as.Date(12/31/02, format = %m/%d/%y), by = 1) len1 = length(date1); data1 = zoo(matrix(rnorm(len1, mean=0, sd=SD*0.5), nrow = len1),  date1) plot(data1) Now I want to

[R] expand.grid() function

2008-06-23 Thread Megh Dal
Hi, I have one question on expand.grid() function. When I write following syntax :expand.grid(c(u, l), c(u, l), c(u, l)) I get following as desired : Var1 Var2 Var3 1uuu 2luu 3ulu 4llu 5uul 6lul 7ul

[R] write.table() error

2008-06-05 Thread Megh Dal
Hi, I got following error in write.table() : write.table(dataa, file=c:/data1.csv, row.names=F, col.names=T, sep=,) Error in file(file, ifelse(append, a, w)) : cannot open the connection In addition: Warning message: In file(file, ifelse(append, a, w)) : cannot open file 'c:/data1.csv':

[R] Creating zoo object on monthly time series

2008-06-01 Thread Megh Dal
Hi all, I have following monthly time series : head(data1) V1 V2 V3 1 Nov-80 NA 1007.44 2 Dec-80 NA 982.05 3 Jan-81 NA 994.25 4 Feb-81 NA 996.31 5 Mar-81 NA 939.91 6 Apr-81 NA 923.32 Now I want to convert it to a 'zoo' object. I wrote following syntax : ss = zoo(data1[,3],

Re: [R] Creating zoo object on monthly time series

2008-06-01 Thread Megh Dal
-01 0005-01-01 0006-01-01 1206.68 782.451187.001398.771883.231431.80 Nowhere 1980 is coming. Any better suggestion? Gabor Grothendieck [EMAIL PROTECTED] wrote: On Sun, Jun 1, 2008 at 8:47 AM, Gabor Grothendieck wrote: On Sun, Jun 1, 2008 at 8:35 AM, Megh Dal wrote: Hi

Re: [R] Creating zoo object on monthly time series

2008-06-01 Thread Megh Dal
, 2008 at 9:37 AM, Megh Dal wrote: I got following: z - zoo(data1[,3], as.yearmon(data1[,1], %b-%y)) head(z) Jan 0001 Jan 0002 Jan 0003 Jan 0004 Jan 0005 Jan 0006 1206.68 782.45 1187.00 1398.77 1883.23 1431.80 z - zoo(data1[,3], as.Date(as.yearmon(data1[,1], %b-%y))) head(z) 0001-01

Re: [R] Creating zoo object on monthly time series

2008-06-01 Thread Megh Dal
provide the dput output as requested. On Sun, Jun 1, 2008 at 9:59 AM, Megh Dal wrote: packageDescription(zoo)$Version [1] 1.1-1 Gabor Grothendieck wrote: You need to unambiguously specify what your data looks like. Please provide the dput output as previously requested. Also what version

Re: [R] Solution of function

2008-05-09 Thread Megh Dal
Still I did not find any suggestion. Is my problem not elaborate enough? Megh Dal [EMAIL PROTECTED] wrote: I think I should be clear exactly what I want : take following example : a = b = seq(1, 5, by=500) v = matrix(0, nrow=length(a), ncol=length(a)) for (i in 1:length

[R] solve.QP() error

2008-05-08 Thread Megh Dal
I got following error while I was using solve.QP() in my problem: Dmat = matrix(c(0.0001741, 0.0001280, 0.0001280, 0.0002570), nrow=2) dvec = t(c(0,0)) Amat = matrix(c(-1,1,0,-1,0, 1,0,1,0,-1), nrow=5) bvec = c(-2, 1, 1, -5, -5) solve.QP(Dmat,dvec,Amat,bvec=bvec) Error in

[R] Solution of function

2008-05-07 Thread Megh Dal
Hi, I want to find solution of function : f(x,y) = x'Cx - a under constraints : 0 x,y p 0 x-y q where a, p,q are given constants and x = (x, y) and C is a 2X2 matrix (given) Can anyone suggest me any R function to do that?

[R] Fwd: Re: Solution of function

2008-05-07 Thread Megh Dal
Forgot to send one copy to R help. Sorry Megh Dal [EMAIL PROTECTED] wrote: Date: Wed, 7 May 2008 02:45:09 -0700 (PDT) From: Megh Dal [EMAIL PROTECTED] Subject: Re: [R] Solution of function To: Berwin A Turlach [EMAIL PROTECTED] Hi Berwin, Thanks for having look on my problem. However

Re: [R] Solution of function

2008-05-07 Thread Megh Dal
is the corresponding component values of x. Any suggestion please? Peter Dalgaard [EMAIL PROTECTED] wrote: Megh Dal wrote: Hi, I want to find solution of function : f(x,y) = x'Cx - a under constraints : 0 x,y p 0 x-y q where a, p,q are given constants and x = (x, y) and C

[R] How to put different color in some portion of a surface plot?

2008-05-06 Thread Megh Dal
Hi all, I have following problem : a = b = seq(1, 5, by=500) v = matrix(0, nrow=length(a), ncol=length(a)) for (i in 1:length(a)) { for (j in 1:length(a)) { d = c(17989*a[i], -18109*b[j]) v[i,j] = t(d) %*% matrix(c(0.0001741, 0.0001280, 0.0001280,

[R] Constructing dummy variables for months for a time series object

2008-04-25 Thread Megh Dal
I have a TS of monthly observations. head(data4) 1991(1) 1991(2) 1991(3) 1991(4) 1991(5) 1991(6) 12.00864 11.94203 11.98386 12.01900 12.19226 12.15488 Now I want to make 11 dummy variables indicating months. Therefore I did followings : For Jan : rep(c(rep(0,0), 1,

[R] Incompleteness (or bug ?) in mAr.est for VAR estimation

2008-03-24 Thread Megh Dal
Hi all, I feel there is a incompleteness in mAr.est function in mAr package for VAR estimation. I does not cheak whether there is multicolinearity in data set. Here I used mAr.est function for following dataset : head(log(data1) + ) V1 V2 V3 V4 V5

Re: [R] How to create following chart for visualizing multivariate time series

2008-03-15 Thread Megh Dal
) etc However I can not reproduce this example in my problem. How I can change my data matrix 'dat' to 'Z' ? If anyone show me some light it would be great for me. Regards, Megh Dal [EMAIL PROTECTED] wrote: Roy Mendelssohn [EMAIL PROTECTED] wrote: Date: Thu, 28 Feb 2008 20

[R] Fwd: Re: How to create following chart for visualizing multivariate time series

2008-03-15 Thread Megh Dal
tried with image() function [however there is also no option to put a color pallet :( ], there is a option 'zlim' to trim the not-required values. Is there any option in levelplot() function as well? I already gone through it's help file, however got nothing on that Megh Dal [EMAIL PROTECTED

[R] Error in extracting monthly observation from a daily time series data

2008-03-10 Thread Megh Dal
Hi all, Suppose I have following dataset : library(zoo) SD = 1 date1 = seq(as.Date(01/01/90, format = %m/%d/%y), as.Date(12/31/08, format = %m/%d/%y), by = 1) len1 = length(date1); data1 = zoo(matrix(rnorm(len1, mean=0, sd=SD*0.5), nrow = len1), date1) Now I want to extract

[R] Formating a zoo dataset .

2008-03-02 Thread Megh Dal
Suppose I have following dataset : head(data1) Date Return 1 03/31/00 0.14230650 2 04/28/00 -0.03276228 3 05/31/00 -0.06527890 4 06/30/00 -0.04999873 5 07/31/00 -0.01447902 6 08/31/00 0.22265729 Now I convert it to zoo object : data11 = zoo(data1[,2], as.Date(data1[,1],

[R] A question on getting all possible combinations

2008-03-01 Thread Megh Dal
Hi all, Suppose I have to letters 'u' and 'd'. Now I want to find all combinations like that : uu ud du . dd This type of combination generally required for Option Pricing in financial/derivative market. Here generally 'u' means: up-move and 'd' means down

[R] Fwd: Re: How to create following chart for visualizing multivariate time series

2008-02-28 Thread Megh Dal
tell me how to do that, it will be good for me. Regards, Megh Dal [EMAIL PROTECTED] wrote: Hi all, Can anyone here please tell me whether is it possible to produce a chart displayed in http://www.datawolf.blogspot.com/ in R for visualizing multivariate time series? If possible how? Regards

Re: [R] Fwd: Re: How to create following chart for visualizing multivariate time series

2008-02-28 Thread Megh Dal
) r - sqrt(outer(x^2, y^2, +)) image(x, y, r, col=gray((0:32)/32)) colors - colorRampPalette(c('red', 'yellow', 'blue')) # create you color spectrum image(x,y,r, col=colors(100)) On Thu, Feb 28, 2008 at 9:28 PM, Megh Dal wrote: I used ?image function to do that, like below : require(grDevices

[R] Calculating monthly var-cov matrix on non-overlapping rooling window basis

2008-02-27 Thread Megh Dal
let create a 'zoo' object : library(zoo) date.data = seq(as.Date(01/01/01, format = %m/%d/%y), as.Date(06/25/02, format = %m/%d/%y), by = 1) len = length(date.data) data1 = zoo(matrix(rnorm(2*len), nrow = len), date.data ) head(data1) Now I want to create an 3 dimensional

Re: [R] Calculating monthly var-cov matrix on non-overlapping rooling window basis

2008-02-27 Thread Megh Dal
this: lapply(split(data1, format(index(data1), %m)), cov) On 27/02/2008, Megh Dal wrote: let create a 'zoo' object : library(zoo) date.data = seq(as.Date(01/01/01, format = %m/%d/%y), as.Date(06/25/02, format = %m/%d/%y), by = 1) len = length(date.data) data1 = zoo(matrix(rnorm(2*len), nrow

[R] Stat related question : Skew Normal distribution

2008-02-20 Thread Megh Dal
Hi, I would like to ask here one stat related question. Suppose Z ~ Skew-Normal(0,1,1). Now I want to find a variable f: Z - Y which has Z ~ Skew-Normal(0,1,lambda) distribution. Can anyone give me some light how to do that? Regards, -

[R] Stat related question : Skew Normal distribution

2008-02-20 Thread Megh Dal
Hi, I would like to ask here one stat related question. Suppose Z ~ Skew-Normal(0,1,1). Now I want to find a variable f: Z - Y which has Y~ Skew-Normal(0,1,lambda) distribution. Can anyone give me some light how to do that? Regards, -

[R] How to create following chart for visualizing multivariate time series

2008-02-03 Thread Megh Dal
Hi all, Can anyone here please tell me whether is it possible to produce a chart displayed in http://www.datawolf.blogspot.com/ in R for visualizing multivariate time series? If possible how? Regards, - [[alternative HTML version deleted]]

Re: [R] Multiplying each row of a big matrix with a vector

2008-01-30 Thread Megh Dal
(Direct Fax) Please visit our Web site at www.ssga.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Attiglah, Mama Sent: 30 January 2008 11:32 To: Megh Dal; [EMAIL PROTECTED] Subject: Re: [R] Multiplying each row of a big matrix with a vector Ret

[R] Help needed on Normality test

2008-01-29 Thread Megh Dal
Hi all T gurus, I would like to test if my dataset is indeed from N(0, 0.011908969). K.S. test gives following result: ks.test(data, pnorm, 0, 0.011908969) One-sample Kolmogorov-Smirnov test data: data D = 0.1092, p-value = 1.318e-05 alternative hypothesis:

[R] Multiplying each row of a big matrix with a vector

2008-01-29 Thread Megh Dal
I have a big matrix 'ret'. I want to multiply each row of it with a 2nd vector 'pos', resulting result, I want to save in a vector named 'port'. I wrote following code: pos [1] 2593419 2130220 6198197 1673888 198 1784732 2052120 -7490228 -5275000 dim(ret) [1] 500 9

[R] Number of ways to select population members

2007-12-13 Thread Megh Dal
Hi all, Suppose I have a population of 3 alphabets : A, B, C. From this population, number of ways that any 2 can be chosen is 3 i.e. AB, AC, and BC. Is there any R function to generalize this process, for any number of alphabets/numbers and for any sub-sample size? Thanks and

[R] Fetching datapoints from a Time Series

2007-10-24 Thread Megh Dal
Hi all, I have a time series like that : DateValue 01/03/05 -0.008471364 01/04/05 -0.008153802 01/05/05 -0.000780031 01/06/05 -0.000130064 01/07/05 -0.000650576 01/08/05 -0.000130166 01/10/05 -0.004174282 01/11/05 0.01027384 01/12/05 -0.006099558 01/13/05

[R] Fetching datapoints from a Time Series

2007-10-24 Thread Megh Dal
Hi all, I have a time series like that : DateValue 01/03/05 -0.008471364 01/04/05 -0.008153802 01/05/05 -0.000780031 01/06/05 -0.000130064 01/07/05 -0.000650576 01/08/05 -0.000130166 01/10/05 -0.004174282 01/11/05 0.01027384 01/12/05 -0.006099558 01/13/05

[R] Fetching datapoints from a Time Series

2007-10-24 Thread Megh Dal
Hi all, I have a time series like that : DateValue 01/03/05 -0.008471364 01/04/05 -0.008153802 01/05/05 -0.000780031 01/06/05 -0.000130064 01/07/05 -0.000650576 01/08/05 -0.000130166 01/10/05 -0.004174282 01/11/05 0.01027384 01/12/05 -0.006099558 01/13/05

[R] Fetching datapoints from a Time Series

2007-10-24 Thread Megh Dal
Hi all, I have a time series like that : DateValue 01/03/05 -0.008471364 01/04/05 -0.008153802 01/05/05 -0.000780031 01/06/05 -0.000130064 01/07/05 -0.000650576 01/08/05 -0.000130166 01/10/05 -0.004174282 01/11/05 0.01027384 01/12/05 -0.006099558 01/13/05

  1   2   >