sas/stat lecture 1 · copyright © 2013, sas institute inc. all rights reserved....

Post on 30-Sep-2020

7 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

SAS/STAT LECTURE 1

ВВЕДЕНИЕ. ДИСПЕРСИОННЫЙ АНАЛИЗ

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

SAS/STAT ОБЗОР КУРСА

• ANOVA – ДИСПЕРСИООНЫЙ АНАЛИЗ

• LINEAR REGRESSION – ЛЕНЕЙНАЯ РЕГРЕССИЯ

• LOGISTIC REGRESSION – ЛОГИСТИЧЕСКАЯ РЕГРЕССИЯ

• GENMOD: - ОБОБЩЕННЫЕ ЛИНЕЙНЫЕ МОДЕЛИ

• POISSON REGRESSION & ZERO-INFLATED POISSON

• NEGATIVE BINOMIAL REGRESSION

• GAMMA REGRESSION

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ПОМОЩЬ

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

SAS/STAT ГДЕ ИСКАТЬ ПОМОЩИ….

• HTTP://SUPPORT.SAS.COM/DOCUMENTATION/ONLINEDOC/STAT/INDEX.HTML

• HTTP://WWW.MACHINELEARNING.RU

• HTTP://STANFORD.EDU/

• HTTPS://WWW.GOOGLE.RU/

• HTTP://EN.WIKIPEDIA.ORG/WIKI/ANALYSIS_OF_VARIANCE

• PGrebennikov@ibs.ru

• Oleg.Nazarov@sas.com

• Stepan.Vanin@sas.com

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ АНАЛИЗ

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ПРИМЕРЫ ЗАДАЧ

• Действительно ли учителя в среднем зарабатывают меньше бухгалтеров?

• Правда ли у людей получающих новое лекарство уровень лимфоцитов больше чем у

людей получающих плацебо?

• Рыбы живущие в реках около вулканов больше чем рыбы живущие далеко от вулканов?

• Влияет ли осведомленность потребителей о магазинах сети «Перекресток» (высокая,

средняя, низкая) на предпочтение магазинов именно этой сети?

• Как уровень рекламы и/или уровень цен (высокий, средний, низкий) одновременно

влияют на объем продаж товаров данной торговой марки?

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ОБЩАЯ ЗАДАЧА

Есть ли разница между средними характеристики нескольких популяций/выборок/групп?

Или по-другому: «Помогает» ли информация о принадлежности к гр пе предсказать значение исследуемой характеристики?

Response

Continuous

Predictor

Categorical

One-Way ANOVA

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ВВЕДЕНИЕ ПЕРЕМЕННЫЕ

• Variable type

• Continuous / Непрерывные: температура, зарплата, возраст, …

• Categorical (= class) / Категориальные (классовые): образование, пол, тип тарифного плана, регион, …

• Categorical level of measurement

• Nominal / Номинальные: – порядок не определен.

• Ordinal / Ординальные (порядковые): – порядок определен [ => числовые].

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ANOVA И ДРУГИЕ МОДЕЛИ

Type of Predictors

Type of Response

Categorical Continuous Continuous and

Categorical

Continuous Analysis of Variance (ANOVA)

Ordinary Least Squares (OLS)

Regression

Analysis of Covariance (ANCOVA)

Categorical

Contingency Table Analysis or

Logistic Regression

Logistic Regression

Logistic Regression

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ЧЕСНОК

4 Fertilizers / удобрения 32 Beds / грядки

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ GARLIC DATASET

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ГИПОТЕЗА ДИСПЕРСИОННОГО АНАЛИЗА

H0: F1=F2=F3=F4 H1: F1 ≠ F2 or F1 ≠ F3 or F1 ≠ F4 or F2 ≠ F3 or F2 ≠ F4 or F3 ≠ F4

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ОСНОВНАЯ ЛОГИКА ДИСПЕРСИОННОГО АНАЛИЗА

Variability between Groups

Variability within Groups

SST = SSM + SSE

Total Variability

Сум

мы

кв

адр

ато

в

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ СУММЫ КВАДРАТОВ: ПРИМЕР

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ СУММЫ КВАДРАТОВ: ПРИМЕР [TOTAL SUM OF SQUARES]

(3-6)2

(7-6)2

SST = (3-6)2 + (4-6)2 + (5-6)2 + (7-6)2 + (8-6)2 + (9-6)2 = 28

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ СУММЫ КВАДРАТОВ: ПРИМЕР [ERROR SUM OF SQUARES]

SSE = (3-4)2 + (4-4)2 + (5-4)2 + (7-8)2 + (8-8)2 + (9-8)2 = 4

(5-4)2 AY 4

(7-8)2

8BY

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ СУММЫ КВАДРАТОВ: ПРИМЕР [MODEL SUM OF SQUARES]

AY 4

8BY

(8-6)2

(4-6)2

SSM = 3*(4-6)2 + 3*(8-6)2 = 24

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ F STATISTIC AND CRITICAL VALUES AT =0.05

𝑭 . , . =𝑀𝑆𝑀

𝑀𝑆𝐸=

𝑆𝑆𝑀

𝑀𝑜𝑑𝑒𝑙𝐷𝐹𝑆𝑆𝐸

𝐸𝑟𝑟𝑜𝑟𝐷𝐹

ModelDF = число групп -1

ErrorDF=Nobs - 1 - (ModelDF)

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ F STATISTIC SIMPLE “LOGIC”

AY 4

8BY

F >> 1 F ~ 1

R2= SSM / SST

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ СПЕЦИФИКАЦИЯ МОДЕЛИ

Yik = + i + ik

BulbWt = + + Base Level

Fertilizer Unaccounted for Variation

proc glm data=sasuser.MGGarlic;

class Fertilizer;

model BulbWt=Fertilizer;

title 'Testing for Equality of Means with PROC GLM';

run; quit;

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ПРЕДПОЛОЖЕНИЯ

• Observations are independent – независимость наблюдений • Good data collection designs help ensure the independence assumption

• Errors are normally distributed – норм. распр. ошибки • Diagnostic plots from PROC GLM

• All groups have equal variances – однородная дисперсия в группах • PROC GLM produces a test of equal variances with the HOVTEST option in

the MEANS statement. H0 for this hypothesis test is that the variances are equal for all populations

if NO then ask for: MEANS <GROUP-VAR> / HOVTEST WELCH;

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ПРИМЕР

proc glm data=sasuser.MGGarlic plots(only)=diagnostics;

class Fertilizer;

model BulbWt=Fertilizer;

means Fertilizer / hovtest /*WELCH*/;

title 'Testing for Equality of Means with PROC GLM';

run;

quit;

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ РЕЗУЛЬТАТЫ

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ РЕЗУЛЬТАТЫ: ПРОВЕРКА ПРЕДПОЛОЖЕНИЙ

?

Проверка нормальности остатков (случайной ошибки)

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ФАКТОРЫ-ПОМЕХИ

Bulb Weight

Fertilizer

?

?

?

SSE SSM SST

F( , )=MSM / MSE

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ БЛОКИ

4 Fertilizers 32 Beds 8 Sectors

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ OBSERVATIONAL OR RETROSPECTIVE STUDIES

• Groups can be naturally occurring.

• for example, gender and ethnicity

• Random assignment might be unethical or untenable.

• for example, smoking or credit risk groups

• Often you look at what already happened (retrospective) instead of

following through to the future (prospective).

• You have little control over other factors contributing

to the outcome measure.

Design of experiments?

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ CONTROLLED EXPERIMENTS

• Random assignment might be desirable to eliminate selection bias.

• You often want to look at the outcome measure prospectively.

• You can manipulate the factors of interest and can more reasonably

claim causation.

• You can design your experiment to control for other factors

contributing to the outcome measure.

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ДОПОЛНИТЕЛЬНЫЕ ПРЕДПОЛОЖЕНИЯ

• Treatments are randomly assigned within each block.

• The effects of the treatment factor are constant across the levels of the blocking variable.

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ПРИМЕР

proc glm data=sasuser.MGGarlic_Block plots(only)=diagnostics;

class Fertilizer Sector;

model BulbWt=Fertilizer Sector;

title 'ANOVA for Randomized Block Design';

run;

quit;

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ MY GROUPS ARE DIFFERENT. WHAT NEXT?

Dunnett Tukey

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ TUKEY’S MULTIPLE COMPARISON METHOD

This method is appropriate when you consider pairwise comparisons only.

The experimentwise error rate is

• equal to alpha when all pairwise comparisons are considered

• less than alpha when fewer than all pairwise comparisons are

considered.

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ COMPARING TO A CONTROL

Comparing to a control is appropriate when there is a natural reference

group, such as a placebo group in a drug trial.

• Experimentwise error rate is no greater than the stated alpha.

• Comparing to a control takes into account the correlations among tests.

• One-sided hypothesis tests against a control group can be performed.

• Control comparison computes and tests k-1 groupwise differences,

where k is the number of levels of the CLASS variable.

• An example is the Dunnett method.

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ПРИМЕР

proc glm data=sasuser.MGGarlic_Block

plots(only)=(controlplot diffplot(center));

class Fertilizer Sector;

model BulbWt=Fertilizer Sector;

lsmeans Fertilizer / pdiff=all adjust=tukey;

lsmeans Fertilizer / pdiff=control('4') adjust=dunnett;

lsmeans Fertilizer / pdiff=all adjust=t;

title 'Garlic Data: Multiple Comparisons';

run;

quit;

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ TWO-WAY ANOVA WITH INTERACTIONS

Response

Continuous

More than 1 Predictor

n-Way ANOVA

Categorical Predictor

1 Predictor

One-Way ANOVA

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ DRUG EXAMPLE

The purpose of the study is to look at the effect of a new prescription drug on blood pressure.

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ INTERACTIONS

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ NONSIGNIFICANT INTERACTIONS

ijkijjiijkY

ijkjiijkY

Analyze the main effects with the interaction in the model.

…or…

Delete the interaction from the model, and then analyze the main effects.

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ NONSIGNIFICANT INTERACTIONS: GUIDES

Guidelines when to delete the interaction from the model:

• < 5 DF for the error • F-value for the interaction term < 2

Note: when you analyze data from an observational study, it is more common to delete non-significant interaction and then analyze the main effects.

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ПРИМЕР: TWO-WAY ANOVA WITH INTERACTIONS

ods graphics on;

proc glm data=sasuser.drug order=internal;

class DrugDose Disease;

model Bloodp=DrugDose Disease DrugDose*Disease;

lsmeans DrugDose*Disease / slice=Disease;

title 'Analyze the Effects of DrugDose';

title2 'at Each Level of Disease';

format DrugDose dosefmt.;

run;

quit;

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ПРИМЕР: ПРИСУТСТВИЕ ЗНАЧИМОГО ПЕРЕСЕЧЕНИЯ

Линии, соответствующие разным заболеваниям, в зависимости от дозы

не параллельны – значит (возможно) следует исследовать пересечение дозы * заболевания Тесты подтверждают это наблюдение

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

HOME WORK

Copyr i g ht © 2013, SAS Ins t i tu t e Inc . A l l r ights reser ve d .

ДИСПЕРСИОННЫЙ

АНАЛИЗ ДОМАШНЕЕ ЗАДАНИЕ

Рассмотрим эксперимент, в котором мы хотим протестировать три

торговых марки (brands) бетона (concrete) и узнать, делает ли добавка

(additive) бетон каждой марки прочнее. Несколько участков земли

было забетонировано. Следующие характеристики зафиксированы:

Strength – прочность.

Additive – какая добавка была использована.

Brand – марка бетона, подвергшаяся тестированию.

top related