Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Estadística Ciència Política Albert Satorra
ANOVA
Anova: motivació
Estadística Ciència Política . Curs 2004-5 Albert Satorra/Cristina Rata
data = read.table("http://www.econ.upf.edu/~satorra/dades/NotesSemin12.tex", header=T)) > dades P1 P2 TT 1 4.5 5.5 0 26 6.0 5.0 0 .... 41 6.0 4.0 0 42 6.0 3.0 1 43 3.0 3.5 1 44 3.5 4.5 1 45 3.0 5.0 0 49 3.5 4.5 1
anova(lm(P1 ~TT)) Analysis of Variance Table
Response: P1 Df Sum Sq Mean Sq F value Pr(>F) TT 1 2.829 2.829 1.3579 0.2476 Residuals 74 154.153 2.083
anova(lm(P2 ~TT)) Analysis of Variance Table
Response: P2 Df Sum Sq Mean Sq F value Pr(>F) TT 1 55.837 55.837 40.724 1.366e-08 *** Residuals 74 101.462 1.371 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
lapply(split(P1,TT),mean) $`0` [1] 4.6225 $`1` [1] 4.236111
> lapply(split(P2,TT), mean) $`0` [1] 4.925 $`1` [1] 3.208333
L’anàlisi de la variancia (ANOVA) X en diferents grups o poblacions: grups 1, 2, ... G. Mitjana de X en cada grup µg, g=1, …, G.
Hipòtesi nul.la
Ho: µ1 = µ2 = … = µG
Les dades
xij, i=1, 2, …., ng; g=1, 2, …, G
Estadística Ciència Política Albert Satorra
Estadística Ciència Política Albert Satorra
Estadística Ciència Política Albert Satorra
Hores davant de la TV
Estadística Ciència Política Albert Satorra
Hores davant de la TV
Estadística Ciència Política Albert Satorra
> data= read.spss("http://www.econ.upf.edu/~satorra/dades/GSS.SAV", use.value.labels = TRUE, to.data.frame = FALSE,max.value.labels = Inf, trim.factor.names = FALSE,trim_values = TRUE, reencode = NA) > attach(data) > names(data) > logTV= log(TVHOURS +.1) > lm(logTV ~ SEX)
Call: lm(formula = logTV ~ SEX)
Coefficients: (Intercept) SEXFemale 0.84173 0.02141
> anova(lm(logTV ~ SEX)) Analysis of Variance Table
Response: logTV Df Sum Sq Mean Sq F value Pr(>F) SEX 1 0.17 0.17 0.2035 0.652 Residuals 1498 1238.17 0.83
> anova(lm(logTV ~ ZODIAC)) Analysis of Variance Table
Response: logTV Df Sum Sq Mean Sq F value Pr(>F) ZODIAC 12 6.07 0.51 0.6108 0.8346 Residuals 1487 1232.26 0.83 >
> anova(lm(logTV ~ AGE)) Analysis of Variance Table
Response: logTV Df Sum Sq Mean Sq F value Pr(>F) AGE 1 14.55 14.55 17.815 2.581e-05 *** Residuals 1498 1223.78 0.82 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 lm(logTV ~ AGE)
Call: lm(formula = logTV ~ AGE)
Coefficients: (Intercept) AGE 0.594980 0.005582
Estadística Ciència Política Albert Satorra
GET
FILE='G:\Albert\Web\Estadistica\DataSets\GSS.SAV'.
GRAPH
/HISTOGRAM=rincom91 .
FREQUENCIES
VARIABLES=zodiac
/ORDER= ANALYSIS .
ONEWAY
rincom91 BY zodiac
/PLOT MEANS
/MISSING ANALYSIS .
EXAMINE
VARIABLES=rincom91 BY zodiac /PLOT=BOXPLOT/STATISTICS=NONE/NOTOTAL.
GRAPH
/ERRORBAR( CI 95 )= rincom91 BY zodiac . Estadística Ciència Política
Albert Satorra
Estadística Ciència Política Albert Satorra
Exercici: feu el mateix per hores davant TV i VOT92
Estadística Ciència Política Albert Satorra
> dd=factor(as.character(VOTE92), exclude=c( "NAP" , "NOT ELIGIBLE", "REFUSED" , "DK" , "NA" )) > lm(logTV ~ dd)
Call: lm(formula = logTV ~ dd)
Coefficients: (Intercept) ddVOTED 0.9557 -0.1492
> anova(lm(logTV ~ dd)) Analysis of Variance Table
Response: logTV Df Sum Sq Mean Sq F value Pr(>F) dd 1 6.64 6.64 8.5176 0.003572 ** Residuals 1450 1130.52 0.78 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 >
Estadística Ciència Política . Curs 2004-5 Albert Satorra/Cristina Rata
Tables of the F distribution
E:\Estadistica\TABLES.PDF
Estadística Ciència Política Albert Satorra
Estadística Ciència Política Albert Satorra