Hi Jaap,
>> Could anybody please direct me in finding an updated version of this
>> document, or help me
>> correct the code given in the file. The (out-of-date) code is as
follows:
You are not helping yourself, or anyone else, by not including the error
messages you get when trying to execute "your" code. The matter is in
fact
quite straightfowards: ev does not accept an evaluation structure called
grid. The current documentation for locfit does tell you this: ?locfit.raw
(sub ev). When I executed your code I got
> fit1 <- locfit( ~ claw54, deg = 0, kern = "gauss", alpha =
c(0, 0.315),
> ev =
+ grid(100, ll = -3.5, ur = 2.7))
Error in grid(100, ll = -3.5, ur = 2.7) :
unused argument(s) (ll = -3.5, ur = 2.7)
This explicitly tells you that the problem lies with the call to ev grid(...),
which should in fact be ev = lfgrid(...). The following works for
me and should do so for you.
fit1 <- locfit( ~ claw54, deg = 0, kern = "gauss", alpha = c(0,
0.315), ev =
lfgrid(100, ll = -3.5, ur = 2.7))
HTH,
Mark.
R version 2.10.0 Under development (unstable) (2009-06-20 r48806)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_South Africa.1252 LC_CTYPE=English_South Africa.1252
[3] LC_MONETARY=English_South Africa.1252 LC_NUMERIC=C
[5] LC_TIME=English_South Africa.1252
attached base packages:
[1] splines stats graphics grDevices utils datasets methods
base
other attached packages:
[1] locfit_1.5-4 lattice_0.17-25 akima_0.5-2 DPpackage_1.0-7
ade4_1.4-11 Design_2.2-0
[7] survival_2.35-4 Hmisc_3.6-0
loaded via a namespace (and not attached):
[1] cluster_1.12.0 grid_2.10.0 tools_2.10.0
Van Wyk, Jaap wrote:>
> I am trying to reproduce Figure 10.5 of Loader's book: Local Regression
> and Likelihood. The code provided in the book does not seem to work.
> I have managed (a while ago) to get the accompanied R-code for the figures
> in the book (file called lffigs.R) from somewhere - cannot find it on the
> web anymore. The code in the .R script file does not work either.
> Could anybody please direct me in finding an updated version of this
> document, or help me correct the code given in the file. The (out-of-date)
> code is as follows:
>
> data(claw54)
> fit1 <- locfit( ~ claw54, deg = 0, kern = "gauss", alpha =
c(0, 0.315),
> ev > grid(100, ll = -3.5, ur = 2.7))
> fit2 <- locfit( ~ claw54, deg = 0, kern = "gauss", alpha =
c(0, 0.985),
> ev > grid(100, ll = -3.5, ur = 2.7))
> x <- seq(-3.5, 2.7, length.out = 200)
> y <- dnorm(x, -1., 0.1) + dnorm(x, -0.5, 0.1) + dnorm(x, 0, 0.1) +
> dnorm(x,
> 0.5, 0.1) + dnorm(x, 1., 0.1)
> y <- (y + 5 * dnorm(x))/10
> plot(fit1, get.data = T, main = "h=0.315", ylim = c(0, max(y)))
> lines(x, y, lty = 2)
> plot(fit2, get.data = T, main = "h=0.985", ylim = c(0, max(y)))
> lines(x, y, lty = 2)
>
> THANKS FOR ANY ASSISTANCE.
> ps: This code differs from that in the book. I have tried both, without
> success. Even if I just use, for example,
> fit1 <- locfit( ~ claw54, deg = 0, kern = "gauss", alpha =
c(0, 0.315))
> I do not get the same result.
>
> Jacob L van Wyk, Dept. of Statistics, University of Johannesburg (APK),
> Box 524, Auckland Park, 2006.
> Office: +27 11 559 3080, Fax: +27 11 559 2499
>
>
> ________________________________
> This email and all contents are subject to the following disclaimer:
>
> http://www.uj.ac.za/UJ_email_legal_disclaimer.htm
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
>
--
View this message in context:
http://www.nabble.com/The-Claw-Density-and-LOCFIT-tp24218274p24220007.html
Sent from the R help mailing list archive at Nabble.com.