R has introduced a new function xtfrm and in order for zoo to work with it there must be an xtfrm zoo method. The development version of zoo has such a method but its not yet released. Try this:
xtfrm.zoo <- coredata and then run your code. On Sun, Nov 16, 2008 at 12:20 PM, Tolga Uzuner <[EMAIL PROTECTED]> wrote: > Dear Gabor, > > Many thanks. That snippet of code also works for me (below). I am currently > on 2.8.0. > > However, it continues to fail on the specific data I am using. I have > attached the data in data.RData, attached here. If you save this file into > the working directory and run the following, that should illustrate the > problem. > > library(zoo) > load("data.RData") > regrlm<-lm(foo~bar+baz) > regrlm > summary(regrlm) > > If you get the chance, would be interested to see if it fails for you as > well. > > Thanks again, > Tolga > > ############ Gabor's code #################### >> library(zoo) >> z <- 1:10 >> x <- z*z >> y <- x*z >> lm(z ~ x + y) > > Call: > lm(formula = z ~ x + y) > > Coefficients: > (Intercept) x y > 1.24700 0.20194 -0.01164 > >> summary(lm(z ~ x + y)) > > Call: > lm(formula = z ~ x + y) > > Residuals: > Min 1Q Median 3Q Max > -0.43730 -0.14095 0.01808 0.19070 0.26702 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 1.246998 0.179253 6.957 0.000220 *** > x 0.201943 0.015878 12.718 4.3e-06 *** > y -0.011642 0.001579 -7.375 0.000153 *** > --- > Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > Residual standard error: 0.2598 on 7 degrees of freedom > Multiple R-squared: 0.9943, Adjusted R-squared: 0.9926 > F-statistic: 607.6 on 2 and 7 DF, p-value: 1.422e-08 > >> sessionInfo() > R version 2.8.0 (2008-10-20) > i386-pc-mingw32 > > locale: > LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United > Kingdom.1252;LC_MONETARY=English_United > Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] lpSolve_5.6.4 leaps_2.7 nortest_1.0 > [4] numDeriv_2006.4-1 bcp_2.1 snow_0.3-3 > [7] fArma_270.74 fBasics_280.74 timeSeries_280.78 > [10] timeDate_280.80 PerformanceAnalytics_0.9.7.1 tseries_0.10-16 > [13] quadprog_1.4-11 vars_1.4-0 urca_1.1-7 > [16] MASS_7.2-44 MSBVAR_0.3.2 coda_0.13-3 > [19] lattice_0.17-15 xtable_1.5-4 KernSmooth_2.22-22 > [22] RODBC_1.2-3 corrgram_0.1 nlme_3.1-89 > [25] lmtest_0.9-21 car_1.2-9 strucchange_1.3-4 > [28] sandwich_2.1-0 zoo_1.5-4 > > loaded via a namespace (and not attached): > [1] grid_2.8.0 tools_2.8.0 >> > > > > Gabor Grothendieck wrote: >> >> Try upgrading to R 2.8.0 patched. This works for me >> using R 2.8.0 patched from Nov 10th: >> >> library(zoo) >> z <- 1:10 >> x <- z*z >> y <- x*z >> lm(z ~ x + y) >> summary(lm(z ~ x + y)) >> >> >>> >>> packageDescription("zoo")$Version >>> >> >> [1] "1.5-4" >> >>> >>> R.version.string # Vista >>> >> >> [1] "R version 2.8.0 Patched (2008-11-10 r46884)" >> >> >> On Sun, Nov 16, 2008 at 7:32 AM, Tolga Uzuner <[EMAIL PROTECTED]> >> wrote: >> >>> >>> Dear R Users, >>> >>> I am having a weird problem. I have three zoo time series, foo, bar and >>> baz. >>> I run a simple linear regression with foo as the dependent and bar+baz as >>> independents. Even though the regression runs fine, summary seems to >>> fail.The code is below. I am happy to send the data along. I am on R >>> 2.8.0 >>> and Windows XP SP2. Traceback (below, a ton of numbers cut out to make it >>> readable but I can provide the data). reveals the problem is in a >>> function >>> called gt. sessioninfo is at the bottom. >>> >>> Any suggestions ? I upgraded to 2.8.0 this morning after replaced 2.7.1 >>> and >>> I almost feel the new version is at fault but I could be inferring too >>> much... >>> >>> Thanks in advance, >>> Tolga >>> >>> cooks.distance also reveals the same problem. >>> >>> >>>> >>>> length(foo) >>>> >>> >>> [1] 258 >>> >>>> >>>> length(foo) >>>> >>> >>> [1] 258 >>> >>>> >>>> length(bar) >>>> >>> >>> [1] 258 >>> >>>> >>>> length(baz) >>>> >>> >>> [1] 258 >>> >>>> >>>> regrlm<-lm(foo~bar+baz) >>>> regrlm >>>> >>> >>> Call: >>> lm(formula = foo ~ bar + baz) >>> >>> Coefficients: >>> (Intercept) bar baz 1082.39 12.72 -20176.67 >>> >>>> >>>> summary(regrlm) >>>> >>> >>> Call: >>> lm(formula = foo ~ bar + baz) >>> >>> Residuals: >>> Error in if (xi == xj) 0L else if (xi > xj) 1L else -1L : >>> argument is of length zero >>> >>>> >>>> traceback() >>>> >>> >>> 19: .gt(c(145.181456007549, 118.279525850693, 111.250750147955, >>> 89.1393551953539, >>> MANY MANY NUMBERS >>> -67.9948569260507, -146.080176235300), 250L, 246L) >>> 18: switch(ties.method, average = , min = , max = .Internal(rank(x[!nas], >>> ties.method)), first = sort.list(sort.list(x[!nas])), random = >>> sort.list(order(x[!nas], >>> stats::runif(sum(!nas))))) >>> 17: rank(x, ties.method = "min", na.last = "keep") >>> 16: as.vector(rank(x, ties.method = "min", na.last = "keep")) >>> 15: xtfrm.default(x) >>> 14: xtfrm(x) >>> 13: FUN(X[[1L]], ...) >>> 12: lapply(z, function(x) if (is.object(x)) xtfrm(x) else x) >>> 11: order(x, na.last = na.last, decreasing = decreasing) >>> 10: `[.zoo`(x, order(x, na.last = na.last, decreasing = decreasing)) >>> 9: x[order(x, na.last = na.last, decreasing = decreasing)] >>> 8: sort.default(x, partial = unique(c(lo, hi))) >>> 7: sort(x, partial = unique(c(lo, hi))) >>> 6: quantile.default(resid) >>> 5: quantile(resid) >>> 4: structure(quantile(resid), names = nam) >>> 3: print.summary.lm(list(call = lm(formula = foo ~ bar + baz), terms = >>> foo ~ >>> bar + baz, residuals = c(145.181456007549, 118.279525850693, >>> MANY MANY NUMBERS -97.6817272270226, -101.621851940748, >>> -67.9948569260507, >>> -146.080176235300 >>> ), coefficients = c(1082.39330190496, 12.7191319384837, >>> -20176.6660075191, >>> 36.7646530199551, 0.752346859475059, 1097.00127070372, 29.4411401439708, >>> 16.9059414262171, -18.3925639343844, 5.30095123419022e-84, >>> 1.60626441787295e-43, >>> 1.15247513614373e-48), aliased = c(FALSE, FALSE, FALSE), sigma = >>> 90.0587318356495, >>> df = c(3L, 255L, 3L), r.squared = 0.767559392535633, adj.r.squared = >>> 0.765736328947677, >>> fstatistic = c(421.027219021081, 2, 255), cov.unscaled = >>> c(0.166651523684348, >>> -0.00308410770161002, -3.08083131687658, -0.00308410770161002, >>> 6.9788613558326e-05, 0.0263943284503598, -3.08083131687658, >>> 0.0263943284503598, 148.375640597725))) >>> 2: print(list(call = lm(formula = foo ~ bar + baz), terms = foo ~ >>> bar + baz, residuals = c(145.181456007549, 118.279525850693, >>> MANY MANY NUMBERS >>> -97.6817272270226, -101.621851940748, -67.9948569260507, >>> -146.080176235300 >>> ), coefficients = c(1082.39330190496, 12.7191319384837, >>> -20176.6660075191, >>> 36.7646530199551, 0.752346859475059, 1097.00127070372, 29.4411401439708, >>> 16.9059414262171, -18.3925639343844, 5.30095123419022e-84, >>> 1.60626441787295e-43, >>> 1.15247513614373e-48), aliased = c(FALSE, FALSE, FALSE), sigma = >>> 90.0587318356495, >>> df = c(3L, 255L, 3L), r.squared = 0.767559392535633, adj.r.squared = >>> 0.765736328947677, >>> fstatistic = c(421.027219021081, 2, 255), cov.unscaled = >>> c(0.166651523684348, >>> -0.00308410770161002, -3.08083131687658, -0.00308410770161002, >>> 6.9788613558326e-05, 0.0263943284503598, -3.08083131687658, >>> 0.0263943284503598, 148.375640597725))) >>> 1: print(list(call = lm(formula = foo ~ bar + baz), terms = foo ~ >>> bar + baz, residuals = c(145.181456007549, 118.279525850693, >>> MANY MANY NUMBERS -97.6817272270226, -101.621851940748, >>> -67.9948569260507, >>> -146.080176235300 >>> ), coefficients = c(1082.39330190496, 12.7191319384837, >>> -20176.6660075191, >>> 36.7646530199551, 0.752346859475059, 1097.00127070372, 29.4411401439708, >>> 16.9059414262171, -18.3925639343844, 5.30095123419022e-84, >>> 1.60626441787295e-43, >>> 1.15247513614373e-48), aliased = c(FALSE, FALSE, FALSE), sigma = >>> 90.0587318356495, >>> df = c(3L, 255L, 3L), r.squared = 0.767559392535633, adj.r.squared = >>> 0.765736328947677, >>> fstatistic = c(421.027219021081, 2, 255), cov.unscaled = >>> c(0.166651523684348, >>> -0.00308410770161002, -3.08083131687658, -0.00308410770161002, >>> 6.9788613558326e-05, 0.0263943284503598, -3.08083131687658, >>> 0.0263943284503598, 148.375640597725))) >>> >>>> >>>> sessionInfo() >>>> >>> >>> R version 2.8.0 (2008-10-20) >>> i386-pc-mingw32 >>> >>> locale: >>> LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United >>> Kingdom.1252;LC_MONETARY=English_United >>> Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252 >>> >>> attached base packages: >>> [1] stats graphics grDevices utils datasets methods base >>> other attached packages: >>> [1] lpSolve_5.6.4 leaps_2.7 [3] >>> nortest_1.0 >>> numDeriv_2006.4-1 [5] bcp_2.1 >>> snow_0.3-3 [7] fArma_270.74 >>> fBasics_280.74 >>> [9] timeSeries_280.78 timeDate_280.80 >>> [11] >>> PerformanceAnalytics_0.9.7.1 tseries_0.10-16 [13] >>> quadprog_1.4-11 >>> vars_1.4-0 [15] urca_1.1-7 >>> MASS_7.2-44 [17] MSBVAR_0.3.2 coda_0.13-3 >>> [19] lattice_0.17-15 xtable_1.5-4 >>> [21] >>> KernSmooth_2.22-22 RODBC_1.2-3 [23] corrgram_0.1 >>> nlme_3.1-89 [25] lmtest_0.9-21 >>> car_1.2-9 [27] strucchange_1.3-4 >>> sandwich_2.1-0 >>> [29] zoo_1.5-4 >>> loaded via a namespace (and not attached): >>> [1] grid_2.8.0 tools_2.8.0 >>> ______________________________________________ >>> 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.