Skip to content
Back to formatted view

Raw Message

Message-ID: <5003B39B.4070306@stats.ox.ac.uk>
Date: 2012-07-16T06:24:27Z
From: Brian Ripley
Subject: About dpik function
In-Reply-To: <1342378663039-4636590.post@n4.nabble.com>

On 15/07/2012 19:57, chester123 wrote:
> Hi there and thanks in advance.
>
> Nowadays I am working on the plug-in bandwidth selection with R. Firstly, my

So why use package KernSmooth and not the methods in R itself?

> 1010 data is the return rate from Yahoo Finance.
> Secondly, my code is following:
>> r=read.table("/Users/user/Desktop/research/a.txt",sep=",",header=TRUE)
>> x<-r[8:1010,]
>> library(KernSmooth)
>> dpik(x,scalest="minim",level=2L,kernel="normal",canonical=FALSE,gridsize=401L,range.x=range(x),truncate=TRUE)
>
> But the error happens like this:
> Error in Summary.factor(c(233L, 917L, 381L, 748L, 272L, 242L, 269L, 963L,  :
>    range not meaningful for factors
>
> I don't know what's wrong and i am a rookie, please help with that. Thanks!

So what is 'x'?  We don't know (your code is not reproducible), but it 
sure looks like a factor.  And from the help:

        x: vector containing the sample on which the kernel density
           estimate is to be constructed.

A factor is not a vector (in this sense).

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

PLEASE do as you were asked.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595