#Step 1: load the DLL file. You need to specify your own directory dll.load("c:\\working files\\demos\\masal\\masal\\release\\masal.dll", "masal", "cdecl") #Step 2: Scan the data file. The 1st column must be the subject ID number # and the observations from the same subject must be organized in # consecutive rows. For regression analysis, simply assign different # ID numbers for all observations. The result would be equivalent to # the modified version of MARS by Zhang (1994, Technometrics). # The last column must be the response variable. # The 2nd last column should be the measurement time, and for regression # analysis, enter 1 for this column. # The other covariates are in the middle columns. m_scan("c:\\working files\\demos\\masal\\masal.txt") #Step 3: Inform the number of covariates. In this example, it is 8. ncovs_8 nT_length(m)/(ncovs+2) #Step 4: Specify the covariance that is decomposed into a function of time t: # u0 + u1*sqrt(t) + u2*t. In this example, u1 and u2 are set to zero. For # another example, c(1,1,0) would imply u0 + u1*sqrt(t) vars_c(1, 0, 0) #Step 5: Specify the maximum number of terms. MAXTERMN_20 #Step 6: Specify the highest order of interaction MAXTERM_2 #Step 7: Specify whether certain terms need to be enforced. For starters, don't #worry about this. varNo_c(0) #Step 8: Specify the number of iterations. For regression, iteration = 1. # Otherwise, it is 2. iteration_2 #Step 9: Specify the penalty parameter. For starters, don't worry about this. compl_5 #Step 10: Prepare the message vector that contains the text output of MASAL fitting. m1_vector('character', 10000) #Step 11: Prepare the vector that contains the random coefficients # u0, u1, and u2 (if specifed), the residuals, and the predicted response # value. Most users can ignore these, and use the text output to get # everything they need. resid1_rep(0, 3*nT) #Step 12: It is time to call masal routine in DLL masal1_.C("masal", as.double(m), as.integer(ncovs), as.integer(nT), as.integer(vars), as.integer(MAXTERMN), as.integer(MAXTERM), as.integer(varNo), as.integer(iteration), as.double(compl), as.name(m1), resid1) #masal1[[10]] is the text output #masal1[[11]] is the residual #Step 13: finally , unload the DLL file dll.unload("c:\\working files\\demos\\masal\\masal\\release\\masal.dll")