Dear all, I have the following problem which I cannot solve: data <- numeric (100) for (i in 1:100){ p <- runif(1,min=0,max=1) data[i] <- rnorm(1,mean=2,sd=1) } ke <- density(data,bw="sj",n=61) How can I now find the value of this density function for example ke(0), ke(2) etc. Maybe this is an easy question but I cannot resolve it. Thank you very much for the help. On Fri, Nov 27, 2009 at 3:34 PM, <r-help-request@r-project.org> wrote:> Welcome to the R-help@r-project.org mailing list! > > To post to this list, send your email to: > > r-help@r-project.org > > General information about the mailing list is at: > > https://stat.ethz.ch/mailman/listinfo/r-help > > If you ever want to unsubscribe or change your options (eg, switch to > or from digest mode, change your password, etc.), visit your > subscription page at: > > https://stat.ethz.ch/mailman/options/r-help/nastik1%40gmail.com > > You can also make such adjustments via email by sending a message to: > > R-help-request@r-project.org > > with the word `help' in the subject or body (don't include the > quotes), and you will get back a message with instructions. > > You must know your password to change your options (including changing > the password, itself) or to unsubscribe. It is: > > qwerty > > Normally, Mailman will remind you of your r-project.org mailing list > passwords once every month, although you can disable this if you > prefer. This reminder will also include instructions on how to > unsubscribe or change your account options. There is also a button on > your options page that will email your current password to you. >[[alternative HTML version deleted]]
Anastasia wrote:> Dear all, > > I have the following problem which I cannot solve: > > data <- numeric (100) > for (i in 1:100){ > p <- runif(1,min=0,max=1) > data[i] <- rnorm(1,mean=2,sd=1) > }Er what is "p" doing in there. As far as I can see, you might as well do data <- rnorm(200, 2, 1)> ke <- density(data,bw="sj",n=61)> How can I now find the value of this density function for example ke(0), > ke(2) etc. > Maybe this is an easy question but I cannot resolve it.approxfun is your friend, e.g.:> d <- density(rnorm(200,2,1)) > dd <- approxfun(d) > dd(3)[1] 0.2267764> dd(5)[1] 0.006181384> dd(20) # from default rule=1 in approxfun[1] NA> > Thank you very much for the help. > >And, BTW, please don't hijack old mails for new topics (and in particular, don't show your password to the world):> On Fri, Nov 27, 2009 at 3:34 PM, <r-help-request at r-project.org> wrote: > >> Welcome to the R-help at r-project.org mailing list! >> >> To post to this list, send your email to: >> >> r-help at r-project.org-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907