reg                   package:pad                   R Documentation

_P_A_D - _I_l_l_u_s_t_r_a_t_i_o_n _o_f _r_e_g_r_e_s_s_i_o_n _m_o_d_e_l_s

_D_e_s_c_r_i_p_t_i_o_n:

     These functions takes arguments defining a regression model with
     one or two explanatory variables and plots the data, regression
     model and residuals.

_U_s_a_g_e:

     reg(n.expl, ...)

     reg1(true.model, n.points, range.x, regular, x,  ...)

     reg2(true.model, n.points, range.x1, range.x2,  
          regular, x1, x2, ...)

_A_r_g_u_m_e_n_t_s:

  n.expl: the number of explanatory variables. The only values  allowed
          are 1 or 2.  

true.model: a equation defining the true regression model. Examples of
          specifications are:
           2 + 3*x for one explanatory variable and 
           3 + 2*x1 - 3*x2 for two explanatory variables

range.x, range.x1, range.x2: a two elements numerical vector with
          minimum and maximum values for the explanatory variable  

n.points: number of data points

 regular: logical. 'TRUE' (the default) indicates that values of the
          explanatory variable will be regularly spaced between the
          range of x. 'FALSE' means that values of x will be sampled in
          the range of x   

x, x1, x2: objects (vector) or keyboard input with values of the
          explanatory variable(s). Only used if 'range.x'  and
          'range.y' are not provided. 

     ...: further arguments to be passed to the plot function

_D_e_t_a_i_l_s:

     The main function 'reg' asks for the number of explanatory 
     variables and then calls 'reg1'  or 'reg2' for the  case of one or
     two respectively.

     The function takes a ``true'' model and values for the explanatory
      variable(s) and build the response variable from this,  adding to
     the response variable  an error with variance equivalent to 20% of
     its variance.

     A linear regression model is fitted and results are displayed in
     the graphical device.

_V_a_l_u_e:

     The function 'reg1' produces a 2D plot with data against the
     explanatory variable and adds a line with the fitted regression 
     model.

     If the packages 'scatterplot3d' is available, the function 'reg2'
     produces a 3D plot with data against the  explanatory variables
     and adds a plane with the regression model fitted to the data.

     In both cases a second plot with residuals against fitted value is
     produced.

_A_u_t_h_o_r(_s):

     Peter J. Diggle p.diggle@lancaster.ac.uk 
      Paulo Justiniano Ribeiro Jr. p.ribeiro@lancaster.ac.uk.

_S_e_e _A_l_s_o:

     'lm', 'scatterplot3d'.

_E_x_a_m_p_l_e_s:

     reg(1, "1 + 3*x", n.p = 21, range.x = c(0,20), reg = TRUE)
     reg(1, "1 + 3*log(x^2)", n.p=25, range.x = c(1, 100), reg=TRUE)
     reg(1, "10 - 2*exp(-x/10)", x = 1:30)
     ##
     reg(2, "10 - 5*x1 + 3*x2" , x1 = runif(25), x2 =runif(25))
     reg(2, "1+ 3*sqrt(x1) -2*x2^2" , n.p=50, range.x1=c(10, 30),
         range.x2 =c(1, 5))
     #
     # For an interactive input type:
     ## Not run: 
     reg()
     ## End(Not run)

