User Tools

Site Tools


b:head_first_statistics:visualization
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


Next revision
b:head_first_statistics:visualization [2019/10/10 01:27] – created hkimscil
Line 1: Line 1:
 +정보의 시각화: 첫인상
 +  * {{:info.vis.01.xlsx}}
 +
 +  * Scatter plot 
 +<code># Simple Scatterplot
 +attach(mtcars)
 +plot(wt, mpg, main="Scatterplot Example",
 +   xlab="Car Weight ", ylab="Miles Per Gallon ", 
 +   pch=19)</code>
 +
 +{{:c:ps1-1:2019:pasted:20190909-075028.png}}
 +
 +explanatory (설명) variable at x axis
 +response (반응) at y axis
 +
 +But, it does mean __no causal relationship__ between the two variables. Association between two does not guarantee a causal relationship.  
 +
 +Drawing a line among the data.
 +<code># Add fit lines
 +abline(lm(mpg~wt), col="red") # regression line (y~x)
 +lines(lowess(wt,mpg), col="blue") # lowess line (x,y)</code>
 +{{:c:ps1-1:2019:pasted:20190909-075639.png}}
 +
 +
 +A bit more fancy line 
 +<code># Enhanced Scatterplot of MPG vs. Weight
 +# by Number of Car Cylinders
 +library(car)
 +scatterplot(mpg ~ wt | cyl, data=mtcars,
 +   xlab="Weight of Car", ylab="Miles Per Gallon",
 +   main="Enhanced Scatter Plot",
 +   labels=row.names(mtcars))</code>
 +{{:c:ps1-1:2019:pasted:20190909-080032.png}}
 +
 +Line can be: 
 +
 +**__관계의 방향 (direction)__**
 +^  관계의 방향  ^^ 
 +| {{:r.positive.png}}  | {{:r.negative.png}}  |
 +
 +
 +**__관계의 모양 (shape)__**
 +^  관계의 모양  ^^ 
 +| {{:r.positive.png}}  | {{:r.curvepositive.png}}  |
 +
 +**__관계의 정도 (힘)__**
 +^  관계의 정도 (힘)  ^^ 
 +| [{{:r.StrengthA.png|Figure_4-1}}]  | [{{:r.StrengthB.png|Figure 4-2}}]  |
 +| [{{:r.StrengthC.png|Figure_4-3}}]  | [{{:r.StrengthD.png|Figure 4-4}}]  |
 +<WRAP clear />
 +Pearson's r 의 의미
 +__Relations, not cause-effect__
 +[{{:r_eg.15.6.png?250 |Figure 6. Correlation And Causation}}] 상관관계 계수는 단순히 두 변인 (x, y) 간의 관계가 있다는 것을 알려줄 뿐, 왜 그 관계가 있는지는 설명하지 않는다. 바꿔 말하면, 충분한 r 값을 구했다고 해서 이 값이 두 변인 간의 '''원인'''과 '''결과'''의 관계를 말한다고 이야기 하면 __안된다__. 예를 들면 아이스크림의 판매량과 성범죄가 서로 상관관계에 있다고 해서, 전자가 후자의 원인이라고 단정할 수 있는 근거는 없다. 이는 연구자의 논리적인 판단 혹은 이론적인 판단에 따른다. 
 +<WRAP clear />
 +
 +__Interpretation with limited range__
 +[{{:r_eg.15.71.png?250 |Figure_7._Correlation_And_Range}}] 
 +[{{:r_eg.15.7b1.png?250 |Figure_7._Correlation_And_Range}}] 
 +데이터의 [[Range]]에 대한 판단에 신중해야 한다. 왜냐 하면, 데이터의 어느 곳을 자르느냐에 따라서 r 값이 심하게 변하기 때문이다. 
 +<WRAP clear />
 +__Outliers__
 +[{{:r_eg.15.8a.png?250 |Figure_7._Correlation_And_Extreme_Data}}] 
 +[{{:r_eg.15.8b.png?250 |Figure_7._Correlation_And_Extreme_Data}}] 
 +위의 설명과 관련하여, 만약에 아주 심한 Outlier가 존재한다면 두 변인 간의 상관관계에 심한 영향을 준다.
 +[{{:pearson-6.png?300 |}}]
 +
 +make it sure that there is __no data entry error__.
 +{{:r.crime.scatterplot.for.single.by.state.jpg}}
 +
 +
 +<WRAP clear />
 +
 +see 
 +https://www.gapminder.org/answers/how-does-income-relate-to-life-expectancy/
 +  * Histogram
 +{{:c:ps1-1:2019:pasted:20190909-103341.png}}
 +    * Life expectancy data: {{:life.exp.csv}}
 +
 +<code>
 +le <- as.data.frame(read.csv("http://commres.net/wiki/_media/life.exp.csv", header=T))
 +colnames(le)[1] <- "c.code" # not really necessary. But, sometimes imported first characters are broken.
 +lea <- le$X2017
 +leb <- lea[complete.cases(lea)]
 +hist(leb, color="grey")
 +</code>
 +
 +[{{:c:ps1-1:2019:pasted:20190909-110252.png|Life expectancy in 2017}}]
 +
 +[{{:c:ps1-1:2019:pasted:20190909-104759.png|Distribution of temperature}}]
 +
 +[{{:c:ps1-1:2019:pasted:20190909-111117.png|skewness}}]
 +
 +[{{:c:ps1-1:2019:pasted:20190909-111001.png|modality}}]
 +
 +box plot
 +<code>
 +# Boxplot of MPG by Car Cylinders
 +boxplot(mpg~cyl,data=mtcars, 
 +    main="Car Milage Data",
 +    xlab="Number of Cylinders",
 +    ylab="Miles Per Gallon")
 +</code>
 +{{:c:ps1-1:2019:pasted:20190909-111438.png}}
 +
  
b/head_first_statistics/visualization.txt · Last modified: 2023/09/11 08:11 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki