---
title: "第一周作业"
documentclass: ctexart
author:
  -  
output:
  rticles::ctex:
    fig_caption: yes
    number_sections: no
    toc: yes
classoption: "hyperref"
---

 
 
## 1.4题

全球10大公司的收益数据(P1.4), (a) 为变量$x_1$和$x_2$作散布图及边缘点图, 并加以解释. (b) 计算$\bar{x}_1, \bar{x}_2, s_{11}, s_{22}, s_{12}$和$r_{12}$, 并解释$r_{12}$

\textbf{解}:(a) 散点图如下

```{r}
P14<-read.table(file="P1-4.dat")
rownames(P14)<-c("Citi","GE","AIG","BOA","HSBC","EM","Shell",
                 "BP","ING","Toyota")
colnames(P14)<-c("sales","profits","assets")
#scatter plot with marginal dot plot
 setup <- c(0.2, 0.8)
 par(oma=c(2,0,2,2))
 layout(matrix(c(3,1,0,2),2,2),width=rev(setup),height=setup)
 par(mar=c(5,4,0,0))
 plot(P14$sales,P14$profits,xlab="sales",ylab="profits")
 text(P14$sales,P14$profits-0.5,row.names(P14))
 par(mar=c(5,0,0,1))
 par(yaxt="n")
 stripchart(P14$profits, "stack", vert=T,pch=19)
 par(mar=c(0,4,1,0))
 par(xaxt="n")
 stripchart(P14$sales, "stack", vert=F,pch=19)
 title(main="The world's 10 Largest Companies",outer=T)
```


散点图表明销售和利润大体上呈现正比例关系, 其中美孚(EM)的销售额和利润均最高, 有聚集现象.  由于样本量比较小, 所以边际分布难以明确.
大致上$x_1$的边际分布呈现右偏现象, 而$x_2$的边际分布看起来是对称的.

 
(b) $\bar{x}_1=155.603, \bar{x}_2=14.704, s_{11}=7476.4532, s_{22}=26.19032, s_{12}=303.61862$ 和$r_{12}=0.6861$, 由$r_{12}$可以看出$x_1$和$x_2$有正的相关关系.

```{r}
sapply(P14,mean)
cov(P14)
cor(P14)
```

## 1.6题


 


