getModelFrame              package:gnm              R Documentation

_G_e_t _t_h_e _M_o_d_e_l _F_r_a_m_e _i_n _U_s_e _b_y '_g_n_m'

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

     A utility function to enable 'gnm' plug-in functions to get the
     model frame in use by 'gnm'.

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

     getModelFrame()

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

     The model frame in use by 'gnm'.

_N_o_t_e:

     This function is only designed to work from within a plug-in
     function. To extract the model frame from a 'gnm' object, use
     'model.frame'.

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

     Heather Turner

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

     'gnm', 'Dref', 'MultHomog'

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

     ## Create a dummy plug-in function
     dummy <- function(...) {
         cat("Model frame:\n")
         print(getModelFrame()[1:5,])
         stop("Not a valid plug-in function, model can not be estimated")
     }

     ##  Use data from Vargas et al (2001)
     set.seed(1)
     data(wheat)
     yield.scaled <- wheat$yield * sqrt(3/1000)
     treatment <- factor(paste(wheat$tillage, wheat$summerCrop, wheat$manure,
                               wheat$N, sep = ""))

     ##  Add dummy nonlinear term to main effects model - the dummy function
     ##  gets the model frame used by gnm and prints the first 5 rows
     mainEffects <- try(gnm(yield.scaled ~ year + treatment +
                            Nonlin(dummy(as.numeric(year), N, scale(MTD))),
                            family = gaussian, data = wheat))

