Anda di halaman 1dari 10

TUGAS TUTORIAL 1:

DISTRIBUSI NORMALITAS DATA

File: Honolulu.dta
------------------------------------------------------------------------------
---------------------------------------------------------
name: <unnamed>
log: C:\DATA\DATA STATA\Tutorial Uji Normalitas Data.log
log type: text
opened on: 22 Nov 2014, 07:49:54

. *command log using digunakan agar semua command and analysis yang akan
dilakukan tersimpan dalam sebuah file yang bisa dibuka lagi*

. *lanjutkan dengan dengan membuka file*

. *dalam tugas tutorial I ini file yang dibuka honolulu*

. use "C:\DATA\DATA STATA\honolulu.dta", clear

. des

Contains data from C:\DATA\DATA STATA\honolulu.dta


obs: 100
vars: 12 21 Nov 2014 23:00
size: 2,600 (99.9% of memory free)
-----------------------------------------------------------------------------
storage display value
variable name type format label variable label
-----------------------------------------------------------------------------
id byte %8.0g
edu byte %8.0g
weight byte %8.0g Weight
height int %8.0g Height
age byte %8.0g Age
smoking byte %8.0g Smoking
physical byte %8.0g Physical
blood int %8.0g Blood
cholesterol int %8.0g
systolic int %8.0g Systolic
bmi float %8.0g
-----------------------------------------------------------------------------
Sorted by:

. sum weight height age physical blood cholesterol systolic bmi

Variable | Obs Mean Std. Dev. Min Max


-------------+--------------------------------------------------------
weight | 100 64.22 8.610048 47 91
height | 100 161.75 5.596491 150 175
age | 100 53.67 5.101109 46 67
physical | 100 1.51 .5024184 1 2
blood | 100 151.64 55.57878 37 442
-------------+--------------------------------------------------------
cholesterol | 100 216.96 38.85844 134 382
systolic | 100 130.1 21.20677 92 208
bmi | 100 24.527 3.01608 18.3 33.6

. *sekarang kita uji normalitas variable cholesterol dan bmi sebagai contoh*

. *uji normalitas bisa menggunakan grafik/plot atau uji statististk


normalitas*

. *kita mulai dengan grafik lebih dahulu*

. *1. histogram*

. histogram cholesterol, frequency


(bin=10, start=134, width=24.8)

. *grafik tersebut bisa di tambah garis normalitas*

. histogram cholesterol, normal freq


(bin=10, start=134, width=24.8)

. graph box cholesterol

. *2 dengan menggunakan box plot*

. *lihat hasil grafik blox plot dan pahami artinya*

. histogram bmi, frequency


(bin=10, start=18.299999, width=1.5299999)

. histogram bmi, normal freq


(bin=10, start=18.299999, width=1.5299999)

. graph box bmi

. graph box cholesterol

. *3 menggunakan qnorm*

. pnorm cholesterol

. pnorm bmi

. *dari grafik pnorm, gimana cara mengetahui apakah distribusi normal atau
tidak*

. qnorm cholesterol

. qnorm bmi

. *4 menggunakan uji statistik*

. swilk cholesterol bmi

Shapiro-Wilk W test for normal data

Variable | Obs W V z Prob>z


-------------+--------------------------------------------------
cholesterol | 100 0.95690 3.559 2.816 0.00243
bmi | 100 0.98856 0.944 -0.127 0.55068

. *dari uji tsb, dapat disimpulkan dar P value, hanya bmi yang distribusi data
normal*

. *untuk melihat secara grafik normalitas bisa juga menggunakan command


kdensity*

. kdensity cholesterol

. kdensity cholesterol, normal

. kdensity bmi, normal

. *5, cholesterok tidak normal*

. *lakukan transformasi data*

. *bisa menggunakan command ladder untuk mengetahui bentuk transformasi yang


tepat*

. ladder cholesterol

Transformation formula chi2(2) P(chi2)


------------------------------------------------------------------
cubic choles~l^3 65.77 0.000
square choles~l^2 39.91 0.000
identity choles~l 16.46 0.000
square root sqrt(choles~l) 7.92 0.019
log log(choles~l) 2.37 0.306
1/(square root) 1/sqrt(choles~l) 1.07 0.585
inverse 1/choles~l 4.31 0.116
1/square 1/(choles~l^2) 16.56 0.000
1/cubic 1/(choles~l^3) 33.54 0.000

. *dari hasil ladder kita ketahui hanya tiga cara yang bisa kita lakukan,
salah satunya dengan log*

. *buat variable baru log cholesterol, misalnya kita namakan variable log_cho*

. gen log_cho=log( cholesterol)

. *lalu kita beli label var log_cho dengan nama Log cholesterol*

. label var log_cho "log cholesterol*

. *test kembali secara plot dan statistik*

. kdensity log_cho, normal

. swilk cholesterol log_cho

Shapiro-Wilk W test for normal data

Variable | Obs W V z Prob>z


-------------+--------------------------------------------------
cholesterol | 100 0.95690 3.559 2.816 0.00243
log_cho | 100 0.99157 0.696 -0.803 0.78895

. *log_cho distribusi menjadi normal, p value 0.788, >0.05*

. *tugas tutorial I lakukan uji normalitas untuk variable lainnya*

. *kalau sudah selesai, log close*

. log close
name: <unnamed>
log: C:\DATA\DATA STATA\Tutorial Uji Normalitas Data.log
log type: text
closed on: 22 Nov 2014, 08:15:44

Appendex: Hasil Grafik/Plot


30
20
Frequency
10
0

150 200 250 300 350


cholesterol
30
20
Frequency
10
0

150 200 250 300 350 400


cholesterol
20
15
Frequency
10 5
0

15 20 25 30 35
bmi
bmi Frequency
15 20 25 30 35 0 5 10 15 20

15
20
25
bmi
30
35
Normal F[(cholesterol-m)/s] cholesterol
0.00 0.25 0.50 0.75 1.00 150 200 250 300 350 400

0.00
0.25
0.50
Empirical P[i] = i/(N+1)
0.75
1.00
1.00 0.75
Normal F[(bmi-m)/s]
0.500.25
0.00

0.00 0.25 0.50 0.75 1.00


Empirical P[i] = i/(N+1)
400
300
cholesterol
200
100

100 150 200 250 300


Inverse Normal
35
30
bmi
25 20
15

15 20 25 30 35
Inverse Normal

Kernel density estimate


.01
.008
.004 .006
Density
.002
0

100 200 300 400


cholesterol

Kernel density estimate


Normal density
kernel = epanechnikov, bandwidth = 13.4129
Kernel density estimate
.15
.1
Density
.05
0

15 20 25 30 35
bmi

Kernel density estimate


Normal density
kernel = epanechnikov, bandwidth = 0.9694

Kernel density estimate


2.5
2
1.5
Density
1 .5
0

4.5 5 5.5 6
log cholesterol*

Kernel density estimate


Normal density
kernel = epanechnikov, bandwidth = 0.0622

Anda mungkin juga menyukai