首页 > > 详细

讲解 Lab 9: Real Data Analysis调试数据库编程

Lab 9: Real Data Analysis

SPSS

1. Create codebook

1.1 Simple Codebook

Simple codebook prints most of the information found in the Variable View window. It gives the names, labels, measurement levels, widths, formats, and any assigned missing values labels for every variable in the dataset. It also prints a table with the assigned value labels for categorical variables.

· File > Display Data File Information > Working File

1.2 Detailed Codebook

Detailed codebook includes all of the same information as the simple codebook, but also includes options for printing summary statistics as well. You can choose which variables are included in the codebook, and you can choose which variable properties are included in the summary. The summary information for each variable will be printed in its own table.

· Analyze > Reports > Codebook.

2. Data Manipulation

2.1 Create new variables using a function of existing variables (review previous labs)

· Transform. > Compute Variable

COMPUTE MeanScore=MEAN(satVerbal,satMath).

EXECUTE.

2.2 Record or transform. variable (review previous labs)

· Transform. > Recorded into Different Values

> select “input variable -> output variable”

> define “output name” and its “label”

> select “if” to specify the conditions under which recode will be applied

> specify the “old value” and “new value”

> “add” the rules

> click “Output variables are strings” if in need

n You can also record value based on missingness or range.

2.3 Dichotomizing the continuous variable (review previous labs)

· Transform. > Visual Binning

> make cut points > make labels

· You can also write the syntax by yourself.

* Visual Binning.

*teacherPay.

RECODE  teacherPay (MISSING=COPY) (LO THRU 32.8131654814530=1) (LO THRU 39.34939458005=2) (LO THRU

46.0055544877955=3) (LO THRU HI=4) (ELSE=SYSMIS) INTO teacherPay_group.

VARIABLE LABELS  teacherPay_group 'teacherPay (Binned)'.

FORMATS  teacherPay_group (F5.0).

VALUE LABELS  teacherPay_group 1 '<=32.81' 2 '32.81-39.35' 3 '39.35-46.01' 4 '46.01+'.

VARIABLE LEVEL  teacherPay_group (ORDINAL).

EXECUTE.

2.4 Rank cases

· Transform. > rank cases

> ‘by’ (optional): assign rank within group

> ‘assign rank 1 to’: decreasing or increasing order

A new variable of rank would be created automatically in the data. Weighting also has an influence on the result of rank.

2.5 Sort cases

· Directly right click on the variable in data view > ‘sort ascending’ or ‘sort descending’

· Data > Sort case

> sorted by (you can select multiple variables)

> select sort order for each variable

2.7 Grouping or splitting data

· Data > split file > compare group > group based on (you can group on multiple variables)

After grouping, all the analysis you do will be based on the subgroups.

Using the `state.sav` data as an example, let’s say we want to group the data based on `region_4categs`. Follow the above steps, and save your syntax:

* Group the data based on region_4categs

DATASET ACTIVATE DataSet1.

SORT CASES  BY region_4categs.

SPLIT FILE LAYERED BY region_4categs.

Then, we run regression analysis with say, SATVerbal as dependent variable and TeacherPay and PercentTaking as the covariates. Again, let’s save the syntax.

* Encoding: UTF-8.

* Group the data based on region_4categs

DATASET ACTIVATE DataSet1.

SORT CASES  BY region_4categs.

SPLIT FILE LAYERED BY region_4categs.

* Run regression analysis

DATASET ACTIVATE DataSet1.

REGRESSION

/MISSING LISTWISE

/STATISTICS COEFF OUTS R ANOVA

/CRITERIA=PIN(.05) POUT(.10)

/NOORIGIN

/DEPENDENT satVerbal

/METHOD=ENTER teacherPay percentTaking.

3. Missing Data

3.1 Listwise Exclusion

In listwise deletion a case is dropped from an analysis because it has a missing value in at least one of the specified variables. The analysis is only run on the cases which have a complete set of data.

· Data > select cases > if condition is satisfied > if… > function group: missing values > Nmiss(…) < 1

· Another way is pairwise exclusion: https://www.ibm.com/support/pages/pairwise-vs-listwise-deletion-what-are-they-and-when-should-i-use-them

3.2 Missing data imputation (Use with caution!!)

3.2.1 multiple imputation

· Analysis > Multiple imputation > pattern analysis

· Analysis > Multiple imputation > impute missing values > select variables (variables you used for imputation model) > choose the method > select constrain > output

You can now do the analysis based on the new data

3.2.2 simple imputation

Yes, you can simply impute the missing value with any specific number. For example, the mean of the corresponding variable.

Real Data Example

1. Data

NELS:88 (https://nces.ed.gov/surveys/nels88/)

2. Standing on the shoulders of giants

Ehrenberg, R. G., Goldhaber, D. D., & Brewer, D. J. (1995). Do teachers' race, gender, and ethnicity matter? Evidence from the National Educational Longitudinal Study of 1988. ILR Review, 48(3), 547-561.





联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!