exclude.too.far             package:mgcv             R Documentation

_E_x_c_l_u_d_e _p_r_e_d_i_c_t_i_o_n _g_r_i_d _p_o_i_n_t_s _t_o_o _f_a_r _f_r_o_m _d_a_t_a

_D_e_s_c_r_i_p_t_i_o_n:

     Takes two arrays defining the nodes of a grid over a 2D covariate
     space and two arrays  defining the location of data in that space,
     and returns a logical vector with elements 'TRUE' if  the
     corresponding node is too far from data and 'FALSE' otherwise.
     Basically a service routine for  'vis.gam' and 'plot.gam'.

_U_s_a_g_e:

     exclude.too.far(g1,g2,d1,d2,dist)

_A_r_g_u_m_e_n_t_s:

      g1: co-ordinates of grid relative to first axis.

      g2: co-ordinates of grid relative to second axis.

      d1: co-ordinates of data relative to first axis.

      d2: co-ordinates of data relative to second axis.

    dist: how far away counts as too far. Grid and data are first
          scaled so that the grid lies exactly  in the unit square, and
          'dist' is a distance within this unit square.

_D_e_t_a_i_l_s:

     Linear scalings of the axes are first determined so that the grid
     defined by the nodes in  'g1' and 'g2' lies exactly in the unit
     square (i.e. on [0,1] by [0,1]). These scalings are  applied to
     'g1', 'g2', 'd1' and 'd2'. The minimum Euclidean  distance from
     each node to a datum is then determined and if it is greater than
     'dist' the  corresponding entry in the returned array is set to
     'TRUE' (otherwise to 'FALSE'). The  distance calculations are
     performed in compiled code for speed without storage overheads.

_V_a_l_u_e:

     A logical array with 'TRUE' indicating a node in the grid defined
     by 'g1', 'g2' that  is `too far' from any datum.

_A_u_t_h_o_r(_s):

     Simon N. Wood simon.wood@r-project.org

_R_e_f_e_r_e_n_c_e_s:

     <URL: http://www.stats.gla.ac.uk/~simon/>

_S_e_e _A_l_s_o:

     'vis.gam'

_E_x_a_m_p_l_e_s:

     library(mgcv)
     x<-rnorm(100);y<-rnorm(100) # some "data"
     n<-40 # generate a grid....
     mx<-seq(min(x),max(x),length=n)
     my<-seq(min(y),max(y),length=n)
     gx<-rep(mx,n);gy<-rep(my,rep(n,n))
     tf<-exclude.too.far(gx,gy,x,y,0.1)
     plot(gx[!tf],gy[!tf],pch=".");points(x,y,col=2)

