[R] 2-dimensional probability density surface using thin-plate spline

impromptu@nifty.com impromptu at nifty.com
Tue Jan 21 10:49:03 CET 2003


R-users
E-mail: r-help at stat.math.ethz.ch

     I have a problem with usage of "gss". I would like to obtain
2-dimensional probability density surface using thin-plate spline.
My object is below:

function()
{
# (1)
    library(gss) 
    set.seed(2523)
    xx1 <- c(rnorm(60, mean=3, sd=2), rnorm(40 , mean=9, sd=1))
    xx2 <- c(rnorm(60, mean=4, sd=2), rnorm(40 , mean=10, sd=1))
# (2)
    br1 <- seq(from = floor(min(xx1)*2)/2, to = ceiling(max(xx1)*2)/2+0.5, by = 0.5)
    br2 <- seq(from = floor(min(xx2)*2)/2, to = ceiling(max(xx2)*2)/2+0.5, by = 0.5)
    quad1_expand.grid(br1, br2)
    wt1_rep(1, nrow(quad1))
    data1 <- data.frame(x1 = xx1, x2 = xx2)
    fit1 <- ssden(~x1:x2, data=data1,  type="tp", quad = list(pt=quad1, wt=wt1), order=2,
     domain=data.frame( x1=c(br1[1], br1[length(br1)] ), x2=c(br2[1], br2[length(br2)] )) )
# (3)
    midp1 <- br1[1:(length(br1)-1)]+(br1[2]-br1[1])*0.5 
    midp2 <- br2[1:(length(br2)-1)]+(br2[2]-br2[1])*0.5 
    midpg_expand.grid(midp1, midp2)   
    data2 <- data.frame(x1=midpg[,1], x2=midpg[,2])
    ey <- dssden(fit1, data2) 
    ey_matrix(ey, ncol=length(midp2))   
    print(ey)
}

The result is:

Error in array(x, c(length(x), 1), if (!is.null(names(x))) list(names(x),  : 
        attempt to set an attribute on NULL

   I am just wondering what causes this.

   *****    Kunio Takezawa, Ph.D. (takezawa at affrc.go.jp)    *****
*****     <http://cse.inada.affrc.go.jp/takezawa/patent-c.html>    *****




More information about the R-help mailing list