s                    package:VGAM                    R Documentation

_D_e_f_i_n_i_n_g _s_m_o_o_t_h_s _i_n _V_G_A_M _f_o_r_m_u_l_a_e

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

     's' is used in the definition of (vector) smooth terms within
     'vgam' formulae.

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

     s(x, df = 4, spar = 0, ...)

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

     In the following, M is the number of additive predictors and r is
     the number of component functions to be estimated (so that r is an
     element from the set {1,2,...,M}). Also, if n is the number of
     _distinct_ abscissae, then  's' will fail if n < 7.

       x: covariate (abscissae) to be smoothed.

      df: numerical vector of length r. Effective degrees of freedom:
          must lie between 1 (linear fit) and n (interpolation). 
          Recycling of values will be used if 'df' is not of length r.

    spar: numerical vector of length r.  Positive smoothing parameters
          (after scaling) . Larger values mean more smoothing so that
          the solution approaches a linear fit for that component
          function. A zero value means that 'df' is used.  Recycling of
          values will be used if 'spar' is not of length  r.  

     ...: Ignored for now. 

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

     's', which is symbolic and does not perform any smoothing itself,
     only handles a single covariate. It differs from the S-PLUS 's'
     and also the one from the 'mgcv' library. They should not be mixed
     together. 

     S-PLUS's 's' allowed 'spar' to be negative; 'VGAM' does not allow
     this.

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

     A vector with attributes that are used by 'vgam'.

_N_o_t_e:

     The 'x' argument of 's()' must be a single variable and not a
     function of a variable. For example, 's(x)' is fine but
     's(log(x))' will fail.  In this case, let 'logx <- log(x)', say,
     and use 's(logx)'.

     The vector cubic smoothing spline which 's()' represents is
     computationally demanding for large M. The cost is approximately
     O(M^3).

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

     Thomas W. Yee

_R_e_f_e_r_e_n_c_e_s:

     Yee, T. W. and Wild, C. J. (1996) Vector generalized additive
     models. _Journal of the Royal Statistical Society, Series B,
     Methodological_, *58*, 481-493.

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

     'vgam', 'vsmooth.spline'.

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

     # Nonparametric logistic regression
     data(hunua)
     fit = vgam(agaaus ~ s(altitude, df=3), binomialff, hunua)
     ## Not run: 
     plot(fit, se=TRUE)
     ## End(Not run)

     # Bivariate logistic model with artificial data
     n = 300 
     mydf = data.frame(x1=runif(n), x2=runif(n))
     mydf = transform(mydf, 
         y1 = ifelse(runif(n) < 1/(1+exp(-sin(2*x2))), 1, 0),
         y2 = ifelse(runif(n) < 1/(1+exp(-sin(2*x2))), 1, 0))
     fit = vgam(cbind(y1,y2) ~ x1 + s(x2, 3), trace=TRUE,
                binom2.or(exchangeable = TRUE ~ s(x2,3)), data=mydf)
     coef(fit, matrix=TRUE)
     ## Not run: 
     plot(fit, se=TRUE, which.term= 2, scol="blue")
     ## End(Not run)

