[R] Peculiar behaviour with MatchIt and a function

2010-04-11 Thread Ajay Shah
12L, 8L, 5L, 5L, 10L, 1L, 1L, 4L, 2L, 13L, 13L, 1L, 1L, 5L, 12L, 5L, 10L, 4L, 1L), .Label = c("Chemicals", "Diversified", "Electricity", "Food", "Machinery", "Metals", "Mining", "MiscManuf", "NonMetalMin",

[R] Bug in ecdf? Or what am I missing?

2010-02-27 Thread Ajay Shah
rning message: In xy.coords(x, y, xlabel, ylabel, log) : 1 x value <= 0 omitted from logarithmic plot This seems to be an error since all the values in x are positive. Thanks, -- Ajay Shah http://www.mayin.org/ajayshah aj

Re: [R] [R-SIG-Finance] Sequential MLE on time series with rolling window

2009-11-03 Thread Ajay Shah
ons n to n+T and use it as the starting value for estimation from observations (n+1) to (n+T+1). The two $\hat theta$ values should be similar to each other, hence just one or two iterations should be required in making each step. -- Ajay Shah h

[R] How do I access with the name of a (passed) function

2009-10-17 Thread Ajay Shah
How would I do something like this: f <- function(x, g) { s <- as.character(g) # THIS DOES NOT WORK sprintf("The %s of x is %.0f\n", s, g(x)) } f(c(2,3,4), "median") f(c(2,3,4), "mean") and get the results "The median of x is

[R] Bootstrap inference for the sample median?

2009-08-30 Thread Ajay Shah
om values which are all lower than 1, then any sample median of these bootstrap samples should be lower than 1. The upper cutoff of the 95% confidence interval should also be below 1. Is this a bug in the boot package? Or should I be using `Percentile' or `BCa' in t

[R] Better weight management / weight loss through science

2009-08-22 Thread Ajay Shah
Folks, I wrote some text and code to help people think more clearly about weight loss or weight management. This is at: http://www.mayin.org/ajayshah/MISC/weightloss.html I hope this is useful to others. Do tell me if there are things there which I can improve. -- Ajay Shah

Re: [R] How to do a pretty panel plot?

2009-05-14 Thread Ajay Shah
=1) box(col = "grey") ## Adjust par(mar) for 2nd plot par(mar=c(2,4,0,1)) ## Second plot plot(M$date, M$cospi.PE, type="l", col="black", log="y", xaxs="i", yaxs="i", axes=F, lwd=2, ylab="Cospi

[R] How to do a pretty panel plot?

2009-05-14 Thread Ajay Shah
-- and this is clearly all wrong. * It's supposed to look like one rectangle inside which are two plots. Instead it looks like two separate plots. * The x axis is Dates and the axis labelling doesn't get that. How do I set about making a pretty panel plot of these two series, both of

[R] Stuck on building a package

2009-03-15 Thread Ajay Shah
om package:base : as.Date.numeric Error in parse(n = -1, file = file) : unexpected end of input at 63: ft=winsorised.left, winsorised.right=winsorised.right) 64: } Calls: -> code2LazyLoadDB -> sys.source -> parse Execution halted ERROR: lazy loading failed for package &

[R] Please help me to understand environments

2009-03-15 Thread Ajay Shah
I want to write: zap <- function(v) { if (exists(v)) {rm(v)} } But of course this doesn't work because the rm() acts on v which is within zap() and doesn't affect the parent environment: > x <- 1 > zap("x") > x [1] 1 How would I make this

[R] cbind(NULL,zoo.object)?

2009-03-14 Thread Ajay Shah
tors are of different classes: integer Date Is there an easy workaround; or am I deeply confused; is there a way out? :-) -- Ajay Shah http://www.mayin.org/ajayshah ajays...@mayin.org http://ajayshah

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ajay Shah
b, well then you should by all > means use Matlab. A good chunk of statistical computation involves loops. We are all happy R users. I was surprised to see that we are so far from matlab in the crucial dimension of performance. -- Ajay Shah http://www.may

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ajay Shah
On Sat, Jan 03, 2009 at 06:59:29PM +0100, Stefan Grosse wrote: > On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah wrote: > > AS> system.time(for (i in 1:1000) {a[i] <- a[i] + 1}) > > AS> I wonder what we're doing wrong! > > it is no secret that R doe

[R] R badly lags matlab on performance?

2009-01-03 Thread Ajay Shah
0.0671.5x For loop version0.099242.209 425.5x So the R is 1.5x costlier for the vector version and 425.5x costlier with matlab. I wonder what we're doing wrong! -- Ajay Shah http://www.mayin

[R] Question about regression without an intercept

2008-12-27 Thread Ajay Shah
to understand how this could be. The estimated coefficient of x is quite different between the two cases. There must be an interesting theoretical angle to this. I would greatly appreciate some help in understanding this, and (more generally) in interpreting the R2 of regressions where the intercep

[R] "Heuristic optimisation"?

2008-10-15 Thread Ajay Shah
I wondered was people on this list felt about this article: http://www.voxeu.org/index.php?q=node/2363 which talks about the problems of obtaining sound answers in numerical optimisation in settings such as MLE or NLS. -- Ajay Shah http://www.mayin.org

[R] Puzzled at generating combinations

2008-03-18 Thread Ajay Shah
there's a clean way to do it but I find myself thinking in loops. -- Ajay Shah http://www.mayin.org/ajayshah [EMAIL PROTECTED] http://ajayshahblog.blogspot.com <*(:-? - wizard who doesn

[R] How does one do simple string concatenation?

2008-03-17 Thread Ajay Shah
How does one convert objects c("a","b","c") and "d" into "abcd"? > paste(c("a","b","c"), "d") of course yields [1] "a d" "b d" "c d" -- Ajay S

Re: [R] Reading microsoft .xls format and openoffice OpenDocument files

2008-03-11 Thread Ajay Shah
On Tue, Mar 11, 2008 at 08:57:49AM +0100, Hans-Peter wrote: > > > > I looked at the package (it's > > http://cran.r-project.org/web/packages/xlsReadWrite/index.html) but > > it's windows only. So no joy yet. > > which platform would you need

Re: [R] Reading microsoft .xls format and openoffice OpenDocument files

2008-03-10 Thread Ajay Shah
tension that sounds similar to R-Excel > (connecting R to Calc). Not sure if that helps you any though. I wasn't able to locate this. Could you please describe this further? -- Ajay Shah http://www.mayin.org/ajayshah [EMAIL PROTECTED]

[R] Reading microsoft .xls format and openoffice OpenDocument files

2008-03-07 Thread Ajay Shah
roach this? Am I correct in thinking that our goal is reading OpenDocument files (http://en.wikipedia.org/wiki/OpenDocument) ? -- Ajay Shah http://www.mayin.org/ajayshah [EMAIL PROTECTED] http://ajayshahblog.blogspot.com <*

[R] New data source - now how do we build an R interface?

2008-03-05 Thread Ajay Shah
URLs which can then be wget. There's some javascript going on that I'm not understanding. Perhaps someone on the mailing list can think about this? -- Ajay Shah http://www.mayin.org/ajayshah [EMAIL PROTECTED]

[R] Code for articles in R news?

2007-12-19 Thread Ajay Shah
I went to the article on np in R news 7/2 (October 2007). What's the general technique to get the source code associated with the article as a .R file that I can play with? -- Ajay Shah http://www.mayin.org/ajayshah [EMAIL PROT

[R] How do I obtain the design matrix of an lm()?

2007-10-10 Thread Ajay Shah
I could, of course, do this manually. But it seems that lm() has done all this hard work. I wonder if there's a way to ask him nicely so as to get it. :-) -- Ajay Shah http://www.mayin.org/ajayshah [EMAIL PROTECTED]