把R安装好,在linux命令行中输入 R (大写)回车即可进入R环境。
1. 将准备好的数据读入,要求是行列都分好了的
> butler <- read.table("ButlerGRBs.txt")
用 print(butler) 可以看导入的数据
> print(butler[,1]) 就只显示一列
2. 将要做统计的列找出来,做些数值变换,如果不需要变换的话,这一步可以省
> Eiso <- butler[,5]*1E52
> T90 <- butler[,2]
> Liso <- Eiso*(1+z)/T90
> logLiso <- log10(Liso)
> logEiso <- log10(Eiso)
3. 拟合
> ans3 <- lm(logEiso ~ logLiso)
看结果:
> summary(ans3)
结果是这样的:
Call:
lm(formula = logEiso ~ logLiso)
Residuals:
Min 1Q Median 3Q Max
-1.6892 -0.5139 0.1378 0.4785 0.9500
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 7.63250 5.01848 1.521 0.133
logLiso 0.87287 0.09776 8.929 9.85e-13 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.6781 on 62 degrees of freedom
Multiple R-squared: 0.5625, Adjusted R-squared: 0.5555
F-statistic: 79.72 on 1 and 62 DF, p-value: 9.848e-13
意思是 logEiso=(7.63250+-5.01848)+(0.87287+-0.09776)logLiso
4. 把数据点画出来
> plot(logLiso,logEiso)
> abline(ans4)
这样的:
如果想要输出成ps文件,则
> postscript("Eiso-Liso.ps")
> plot(logLiso,logEiso)
> abline(ans4)
> dev.off()
附录:数据文件
70518 5.3 ± 0.3 0.09 +0.15–0.01 1.161
70611 11.3 ± 0.7 0.5 +0.4–0.1 2.043
070612A 255 ± 5 2.0 +1.8–0.4 0.6174
070721B 330 ± 10 30 +20–10 3.6266
070724A 0.6 ± 0.1 0.0025 +0.0031–0.0007 0.4577
70802 15 ± 1 0.50 +0.52–0.10 2.458
70809 0.76 ± 0.05 0.0013 +0.0015–0.0003 0.21879
070810A 7.7 ± 0.7 0.9 +0.3–0.1 2.171
071010A 22 ± 2 0.13 +0.24–0.02 0.9812
071010B 35 ± 1 1.8 +0.4–0.1 0.94713
71020 4.4 ± 0.4 10 +10–3 2.14514
71031 190 ± 11 3.9 +4.1–0.6 2.69215
71117 6 ± 1 1.9 +0.8–0.3 1.33116
71122 79 ± 8 0.3 +0.5–0.1 1.1417
71227 2.2 ± 0.3 0.03 +0.04–0.01 0.38318
80129 46 ± 4 8 +7–4 4.34919
80210 44 ± 7 5.1 +4.5–0.9 2.6412
80310 362 ± 6 5.9 +10.5–1.0 2.426621
080319B 147 ± 4 400 +200–100 0.93722
080319C 33 ± 5 6 +5–1 1.9523
80330 66 ± 1 0.41 +0.94–0.06 1.5124
80411 58.3 ± 0.8 23 +9–4 1.0325
080413A 46.6 ± 0.2 9 +6–2 2.43326
080413B 7.0 ± 0.7 1.5 ±0.2 1.1027
80430 16 ± 1 0.38 +0.30–0.08 0.76728
80520 3.0 ± 0.4 0.11 +1.45–0.04 1.54529
080603B 59.5 ± 0.8 6 ±1 2.693
80604 125 ± 8 0.7 +0.8–0.1 1.41631
80607 84 ± 1 280 +130–90 3.03632
80605 19.6 ± 0.5 21 +9–4 1.639833
80707 30.3 ± 0.7 0.34 +0.41–0.05 1.2334
80710 140 ± 16 0.8 +0.8–0.4 0.84535
80721 30 ± 3 110 +110–50 2.60236
80804 60 ± 14 16 +17–7 2.20037
80805 110 ± 14 4 +2–2 1.50538
80810 453 ± 8 30 +20–20 3.3539
080905B 104 ± 7 3.4 +3.1–0.6 2.3744
80913 8.2 ± 0.4 7 +7–1 6.741
080916A 63 ± 5 0.81 +0.21–0.09 0.68942
80928 280 ± 19 2.8 +2.4–0.5 1.69243
81007 5.6 ± 0.4 0.07 +0.05–0.01 0.529544
81008 200 ± 18 6 +3–1 1.968545
81028 280 ± 15 11 +3–2 3.03846
81029 170 ± 14 15 +9–7 3.847947
81118 67 ± 8 2.8 +4.4–0.4 2.5848
81121 19 ± 1 16 +15–4 2.51249
081203A 250 ± 44 17 +13–4 2.15
81222 33 ± 2 15 +3–2 2.7751
90102 31 ± 1 14 +10–5 1.54752
90205 11 ± 1 1.2 +1.6–0.2 4.649753
90313 90 ± 11 4.6 +7.0–0.5 3.37554
90418 58 ± 1 9 +6–3 1.60855
90423 12.4 ± 1.0 8 +2–1 8.356
90424 50.3 ± 0.9 2.6 ±0.4 0.54457
90426 1.3 ± 0.1 0.42 +0.72–0.04 2.60958
90510 0.5 ± 0.1 0.3 +0.5–0.2 0.90359
90516 230 ± 15 50 +50–10 4.1096
90519 82 ± 9 15 +13–8 3.8561
90529 80 ± 5 2.5 +1.4–0.5 2.62562
90618 115.2 ± 0.7 15 ±1 0.5463
090715B 268 ± 7 24 +15–5 3.064
90726 51 ± 1 1.8 +2.1–0.4 2.7165
90809 190 ± 30 1.4 +2.4–0.4 2.73766
90812 100 ± 26 19 +17–5 2.45267
没有评论:
发表评论