[R] Error from termplot() with make.panel.svysmooth() for complex survey data

Christopher T. Moore moor0554 at umn.edu
Wed Oct 14 08:38:13 CEST 2009


Greetings,

I am using library(survey) to analyze some complex sample data. After 
fitting a model I tried to use termplot() with make.panel.svysmooth(), but 
I received an error (see below).

Could someone help me interpret the error message so I can make the 
necessary corrections? The make.panel.svysmooth() function seems to work 
fine, and termplot() worked fine after I dropped the smoother. This led me 
to believe that the error is coming from panel.smooth(), but the code for 
that function does not contain the rowsum() and findInterval() functions 
shown in the error message. I should also note that error does not depend 
on the inclusion or omission of missing data, as I tried it both ways.

I'm analyzing private data, so I can't provide a reproducible example, but 
here's the output:
> #################### design <- svydesign(ids=~PSU, weights=~W, 
> strat=~STR, nest=T, data=data) model <- svyglm(fmla, design=design) 
> #works fine as evidenced by summary (not shown) termplot(model, 
> data=model.frame(design), partial.resid=T, se=T, 
> smooth=make.panel.svysmooth(design))
Waiting to confirm page change... Error in rowsum.default(c(rep(0, ngrid), 
w), c(1:ngrid, findInterval(mm[, :
  incorrect length for 'group'
> make.panel.svysmooth(design)
function (x, y, span = 2/3, col.smooth = "red", col = par("col"), 
    bg = NA, pch = par("pch"), cex = 1, ...) 
{
    if (is.null(bandwidth)) 
        bandwidth <- range(x) * span/3
    s <- svysmooth(y ~ x, design = design, bandwidth = bandwidth)
    points(x, y, pch = pch, bg = bg, col = col)
    lines(s[[1]], col = col.smooth, ...)
}
<environment: 0x0225a5d4>
> termplot(model, data=model.frame(design), partial.resid=T, se=T) #works 
> but without smoothing panel.smooth
function (x, y, col = par("col"), bg = NA, pch = par("pch"), 
    cex = 1, col.smooth = "red", span = 2/3, iter = 3, ...) 
{
    points(x, y, pch = pch, col = col, bg = bg, cex = cex)
    ok <- is.finite(x) & is.finite(y)
    if (any(ok)) 
        lines(stats::lowess(x[ok], y[ok], f = span, iter = iter), 
            col = col.smooth, ...)
}
<environment: namespace:graphics>
> sessionInfo()
R version 2.9.2 (2009-08-24) i386-pc-mingw32 attached base packages: [1] 
splines stats graphics grDevices utils datasets methods base other attached 
packages: [1] quantreg_4.38 SparseM_0.80 KernSmooth_2.23-3 survey_3.16 
car_1.2-15 foreign_0.8-37
> ####################

Thanks in advance for any help you can provide.

Regards,
Chris

-- 
Christopher Moore, M.P.P.
Doctoral Student
Quantitative Methods in Education
University of Minnesota
44.9785°N, 93.2396°W
moor0554 at umn.edu
http://umn.edu/~moor0554




More information about the R-help mailing list