File: ps2-3.inp

package info (click to toggle)
gretl 2016d-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 48,620 kB
  • ctags: 22,779
  • sloc: ansic: 345,830; sh: 4,648; makefile: 2,712; xml: 570; perl: 364
file content (29 lines) | stat: -rw-r--r-- 681 bytes parent folder | download | duplicates (10)
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
# PS2.3 -- on covariance and corr. coeff. - Section 2.5
open data2-2 
genr x = colgpa
genr y = hsgpa
genr n = $nobs
# mean of colgpa 			
genr xbar = mean(x)
# s.d. of colgpa 			
genr sx = sd(x)
# mean of hsgpa 			
genr ybar = mean(y)
# s.d. of hsgpa 			
genr sy = sd(y)
# cross product of deviation from mean 	
genr sxy = (x-xbar)*(y-ybar)
# compute covariance 		
genr covxy = sum(sxy)/(n-1)
# compute correlation coefficient 	
genr corxy = covxy/(sx*sy)
# reset sample range 		
smpl 1 1
# print values 		
print xbar sx ybar sy covxy corxy 
# reset sample range                 
smpl 1 427
# same with the corr command 	
corr x y 
# summary statistics                 
summary x y