Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

draper.sh 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  1. #!/usr/bin/env bash
  2. # Testing gmtregress on the data in Draper & Smith [1998]
  3. # Applied Regression Analysis, 3rd Ed, Wiley.
  4. ps=draper.ps
  5. cat << EOF > draper.txt
  6. # Table 1.1 in Draper & Smith, Applied Regression Analysis
  7. 35.3 10.98
  8. 29.7 11.13
  9. 30.8 12.51
  10. 58.8 8.40
  11. 61.4 9.27
  12. 71.3 8.73
  13. 74.4 6.36
  14. 76.7 8.50
  15. 70.7 7.82
  16. 57.5 9.14
  17. 46.4 8.24
  18. 28.9 12.19
  19. 28.1 11.88
  20. 39.1 9.57
  21. 46.8 10.94
  22. 48.5 9.58
  23. 59.3 10.09
  24. 70.0 8.11
  25. 70.0 6.83
  26. 74.5 8.88
  27. 72.1 7.68
  28. 58.1 8.47
  29. 44.6 8.86
  30. 33.4 10.36
  31. 28.6 11.08
  32. EOF
  33. # First plot data and basic LS fit with equation
  34. txt=$(gmt regress -Ey -N2 -Fxm -T25/80/2+n draper.txt -T0 | awk '{printf "85 13 @!y\\303 = %.4f %.4f x\n", $17, $15}')
  35. gmt psbasemap -R20/85/6/13 -JX6.5i/4i -P -Xc -K -Baf -BWSne > $ps
  36. gmt regress -Ey -N2 -Fxym draper.txt | awk '{printf "> error\n%s %s\n%s %s\n", $1, $2, $1, $3}' | gmt psxy -R -J -O -K -W0.25p,red,- >> $ps
  37. gmt psxy -R -J -O -K draper.txt -Sc0.2c -Gblue >> $ps
  38. gmt regress -Ey -N2 -Fxm -T25/80/2+n draper.txt | gmt psxy -R -J -O -K -W2p >> $ps
  39. echo "$txt" | gmt pstext -R -J -O -K -F+jRT+f18p -Dj0.1i >> $ps
  40. # Redo plot and basic LS fit but also show 68%, 95% & 99% confidence band
  41. gmt psbasemap -R -J -O -K -Baf -BWSNe+t"Draper & Smith [1998] Regression" -Y4.75i >> $ps
  42. gmt regress -Ey -N2 -Fxmc -T25/80/1 -C99 draper.txt | gmt psxy -R -J -O -K -L+d -Glightgreen >> $ps
  43. gmt regress -Ey -N2 -Fxmc -T25/80/1 -C95 draper.txt | gmt psxy -R -J -O -K -L+d -Glightorange >> $ps
  44. gmt regress -Ey -N2 -Fxmc -T25/80/1 -C68 draper.txt | gmt psxy -R -J -O -K -L+d -Glightred -W2p >> $ps
  45. gmt psxy -R -J -O -K draper.txt -Sc0.2c -Gblue >> $ps
  46. gmt pslegend -DjTR+w1.65i+jRT+o0.1i/0.1i -R -J -O -F+p1p << EOF >> $ps
  47. S 0.1i s 0.15i lightgreen - 0.25i 99% Confidence
  48. S 0.1i s 0.15i lightorange - 0.25i 95% Confidence
  49. S 0.1i s 0.15i lightred - 0.25i 68% Confidence
  50. EOF
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...