> -----Original Message----- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Nicola > Sturaro Sommacal (Quantide srl) > Sent: Tuesday, November 02, 2010 3:05 AM > To: r-help@r-project.org > Subject: [R] density() function: differences with S-PLUS > > Hello! > > Someone know what are the difference between R and S-PLUS in > the density() > function? > > For example, I would like to reply this simple S-PLUS code in > R, but I don't > understand which parameter I should modify to get the same results. > > S-PLUS CODE: > density(1:1000, width = 4) > > R-CODE: > density(1:1000, bw = 4, window = "g", n = 50, cut = 0.75) > > I obtain the same x values, but different y values. I try > also different > examples, with different parameter.
I needed to use the to= and from= arguments to get the same set of x values in R and S+. E.g., z <- density(x=0, width=3, window="gaussian", n=2001, from=-10, to=10, cut=0.75) gave identical x outputs in R and S+. By using x=0 you can see the difference in the gaussian-based kernel used by R and Splus: plot(z$x, z$y, pch=".", log="y") Splus, as its help("density") states", uses a truncated Gaussian kernel: "The "gaussian" window is truncated at 4 standard deviations (and then scaled appropriately to adjust for the truncated area)." R appears to not truncate the Gaussian kernel. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > Can you help me? > > Thank you in advance. > > Nicola Sturaro > > [[alternative HTML version deleted]] > > ______________________________________________ > 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-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.