HLM 6 Student version analysis steps From HLM 6: Hierarchical Linear and Nonlinear Modeling, Scientific Software International, Inc. 2004 To run an analysis in HLM, four steps are required: 1. 2. 3. 4. The type of model to be fitted must be decided on. An appropriate MDM (Multivariate Data Matrix) file must be created. The model is specified and various statistical and output options specified. The model is run, after which model-based graphs can be obtained. 2. MDM file construction- To inform HLM of the input and file type Data input can be ASCII or from another statistical package. Our examples are input from ASCII files and SPSS data files. 0) If not done so already, sort LEVEL-1 file by LEVEL-2 unit ID 1) After opening HLM6 Student version, open File -> Make new MDM file -> ASCII input -> Stat package input 2) Choose HLM2 from the menu. A make MDM – HLM2 dialog box will open. 3A) Click Browse in the LEVEL-1 file name to open an Open Data File dialog box. Open a level-1 ASCII data file. 4A) Enter the number of variables into the Number of Variables box (not including the ID variable) and data entry format in the Data Format box. (Start with the ID variable using ‘A’ and then the number of columns, like A4; use F for other variables adding the number of total columns with a decimal number indicating number of digits after the decimal, like F12.3 occupies 12 columns with three numbers behind the decimal; use a number before the F to indicate repeated variables, like 4F12.3 has 4 variables of the same format: 12 columns with three numbers behind the decimal. Your final format will have parenthesis around them and be separated by commas, like (A4, 4F12.3) ). 5A) Click Labels to open the Enter Variable Labels dialog box. 6A) Enter the variable names into the boxes. Click OK. 3S) Select SPSS/Windows from the Input File Type pulldown menu 4S) Click Browse in the LEVEL-1 file name to open an Open Data File dialog box 5S) Open the LEVEL-1 SPSS system file. The Choose Variables button will be activated. 6S) Click Choose Variables to open the Choose Variables – HLM2 dialog box and choose the ID and variables by clicking the appropriate check boxes. To deselect, click the box again. 7S) Select the options for missing data in the LEVEL-1. 8S) Click the selection button for measures within persons for the type of nesting of input data if the LEVEL-1 data consist of repeated measures or item response. 9S) Click Browse in the LEVEL-2 file name to open an Open Data File dialog box. 10S) Open a LEVEL-2 SPSS system file. The Choose Variables button below Browse will be activated. 7A) Click the Missing Data button to enter level-1 missing data information. 8A) Click Browse in the Level-2 file name to open an Open Data File dialog box. Open a level-2 ASCII data file. 9A) Enter the number of variables into the Number of Variables box and the data entry format in the Data Format box (see 4A). 10A) Click Labels to open the Enter Variable Labels dialog box for the Level-2 variables. 11A) Enter the variable names into the Variable boxes. Click OK. 11S) Click the Choose Variables to open the Choose Variables – HLM2 dialog box and choose the ID and variables by clicking the appropriate check boxes. 12) Enter an MDM file name in the MDM File Name box. 13) Click Save mdmt file in the MDM template file section to open a Save MDM template file dialog box. Click Save. 14) Note that HLM will also save the input information into another file called CREATEMDM.MDMT when the MDM is created. 15) Click the Make MDM button. A screen displaying the prompts and responses for MDM creation will appear. To check whether the data have been properly read into HLM 1) Click Check Stats to display and check the LEVEL-1 and LEVEL-2 descriptive statistics. 2) Click Done. The HLM window displays the type and name on its title bar and the LEVEL-1 variables on the drop-down menu. 3. Model Specification Step 1: Specification of LEVEL-1 prediction model 1) From the HLM window, open the File menu 2) Choose Create a new model using an existing MDM file to open an Open MDM File dialog box. 3) Click on the name of the outcome variable. Click Outcome variable. The specified model will appear in equation format. 4) Click on the name of a predictor variable and click the type of centering. The predictor will appear on the equation screen and each regression coefficient associated with it will become an outcome in the LEVEL-2 model. Step 2: Specification of the LEVEL-2 predictor model 1) Select the equation containing the regression coefficient(s) to be modeled by clicking on the equation. A listbox for LEVEL-2 variables ( >>LeveL-2<< ) will appear. 2) Click to select the variable(s) to be entered as predictor(s) and the type of centering. 3) HLM allows the model to be displayed in three alternative forms. By default, the model is specified in the notation familiar to users of previous versions of HLM. 4) The model can be displayed in a mixed model form and with complete subscripts for all coefficients present in the model. The mixed model is obtained by clicking the Mixed button at the bottom of the main window. By using the Preferences dialog box accessible via the File menu both the mixed model form and the model with subscripts for all coefficients can be displayed automatically. The model can also be saved as an EMF file for later use in reports and papers. Step 3: To specify LEVEL-1 coefficients as random or non-random The program begins by assuming that only the intercept (βo) is specified as random. The u1 at the end of the β1 equation is grayed out and constrained to zero, i.e. this LEVEL-1 coefficient is specified as “fixed”. To specify the slope as randomly varying, click on the equation for β1 so that the error term u1 is enabled. One can toggle the error term in any of the three following ways: 1) Click on the error term, u1, 2) Type u, or 3) Right-click on the yellow box, which will bring up a single-item menu toggle error term. Click on the button. After specifying the model in steps 1 to 3, a title can be given to the output and the output file can be named as follows. 1) Select Basic Settings to open the Basic Model Specifications – HLM2 dialog box. Enter a title in the Title field and an output file name in the Output file name field. 2) Open the File menu and choose Save As to open a Save command file dialog box. 3) Enter a command file name. 4) Click Run Analysis. A dialog box displaying the iterations will appear. Note: if you wish to terminate the computations before completion, press the Ctrl-C key combination once. This will stop the analysis after the current iteration and provide a full presentation of results based on that iteration. If you press Ctrl-C more than once, however, computation is terminated immediately and all output is lost. Annotated HLM2 output Open the File menu and choose View Output to call up Notepad to look at the results. 4. Model checking based on the residual file 1) Select Basic Settings to open the Basic Model Specifications – HLM2 dialog box. 2) Click Create Residual File to open the Residual File dialog box. For non-student version, click on Level-1 Residual File to open the Level-1 Residual File dialog box. 3) The box displays two columns of variables for the Level-1 and Level-2 variables. The predictor variables in the model are in the Variables in residual file column. 4) Select SPSS residual file type (default) or another file type. 5) Enter a name for the residual file in the Residual File Name box. Click OK. Residual file contents: level-1 l2id Level-2 ID l1resid The difference between the fitted and observed value for each Level-1 unit fitval Fitted value for each Level-1 unit sigma The square root of σ2 y Variables as requested You can create a Level-2 residual file as above, only Click on the Level-2 Residual File to open the Level-2 Residual File dialog box. Residual file contents: level-2 l2id Level-2 ID nj Number of level-1 units chipct Expected value of order statistics for sample size J selected from the Χ(v)2 distribution mdist intovar olsrsvar mdrsvar eb ols fv ec pv pvc Mahalanobis distance, the standardized squared distance of a unit from the center of v-dimensional distribution with v as the number of random effects Natural logarithm of the toal standard deviation within each unit Natural logarithm of the residual standard deviation within each unit based on its least squares regression. Note, this estimate exists only for those units which have sufficient data to compute level-1 OLS estimates Natural logarithm of the residual standard deviation from the final fitted fixed effects model Empirical Bayes residuals Ordinary least squares residuals Fitted values based on estimated level-2 model EB coefficients (sum of fitted and residual) Posterior variances and covariances of level-2 residuals Posterior variances and covariances of random intercept and coefficients Definitions HLM file – command file with paired to specific MDM file MDM file - Multivariate Data Matrix file – to inform HLM of the input and file type mdmt file – MDM template file – the command file saves all the input information entered by the user. It can be re-opened or changed by clicking either the Open mdmt file or the Edit mdmt file button. Rules for format statements (for use with ASCII input) While the input format statement for HLM resembles FORTRAN, only a subset of format options are acceptable. The user may specify: 1. The A format descriptor to read in the ID variable. This is followed by a number of columns that the ID occupies. 2. The F format descriptor (and the E, used to read in numbers with exponents). This may be preceded with a number specifying a repeat value, and needs to be followed by a decimal number specifying both the number of columns that variable occupies and the places to the right of the decimal. 3. For example, 4F12.3 tells HLM that there are four variables in a row occupying 12 columns and that each value has three numbers to the right of the decimal point. 4. The X format descriptor. This is used to skip over a number of columns. For example, 8X skips over eight columns when reading the data. 5. The / (forward slash) format descriptor. This tells HLM to go to the next line of the input file to read data. It is used when each case takes more than one line in the raw data file. 6. Commas have to be inserted to separate each of the descriptors. 7. Unlike FORTRAN, HLM does not allow nesting of parentheses is not allowed (e.g., (4A,4(1X,F12.3)) will not be read properly by HLM programs).