Hi:

On Sat, Nov 6, 2010 at 11:22 PM, evt <ethulin@gmail.com> wrote:

>
> I am guessing this is a very simple question, but this is only my second
> day
> with R so it is all still a bit imposing.
>
> I am trying to run an autocorrelation.
>
> I imported a CSV file, which has one column labeled "logistic".
>
> I ran the command:
> ACF(data$logistic,maxLag=10)
>

This appears to come from the nlme package. If you read its help page,
you'll find that the first object in the argument list is

object any object from which an autocorrelation function can be obtained.
Generally an object resulting from a model fit, from which residuals can be
extracted.

However, I received the error:
> Error in UseMethod("ACF") :
>  no applicable method for 'ACF' applied to an object of class "c('double',
> 'numeric')"
>

Evidently, numeric variables within data frames don't qualify :)

For things like ACFs, PACFs and ARIMA-type models, there is enough
functionality in the base package. Here's one approach, although depending
on your purposes there may be better options:

dat <- data.frame(series = rnorm(300))
str(dat)
# 'data.frame':   300 obs. of  1 variable:
# $ series: num  -0.774 -0.791 0.693 2.468 0.389 ...

# Convert to a time series object; type ?ts to access its help page
# Pay attention to the frequency = argument if your series is periodic
dat$series <- ts(dat$series)
plot(dat$series)
with(dat, acf(series, lag.max = 10))
with(dat, pacf(series, lag.max = 10))

I am thinking perhaps I need to change the data type, but I really don't
> know how (or if that is even the problem).
>

I believe it is the problem. ACF() probably prefers an lme or nlme object as
input, but unless you're attempting to find residual autocorrelation in a
mixed effects model, acf() in the base package as shown above or a similar
function in any of several R packages devoted to time series are likely to
be better options in general.

HTH,
Dennis

>
> Your suggestions are very much appreciated!
> --
> View this message in context:
> http://r.789695.n4.nabble.com/When-using-ACF-receive-error-no-applicable-method-for-ACF-applied-to-an-object-of-class-c-double-num-tp3030615p3030615.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]

