[R] Theil test help
KARSTEN G HOLMQUIST
kgholmquist at wisc.edu
Thu Jul 16 23:53:33 CEST 2009
Hello,
I have a series of questions that I hope will be simple to answer. Basically I would like a code to do the following so that I can compute the distribution free test for the slope of a postulated regression line (Theil test). As I am testing the null hypothesis that slope = 0 against the general alternative the slope does not equal 0, it should be pretty straight-forward.
I have a data frame as follows;
index Score Mean_Temp SD_Mean_Temp
i 10 3.7 0.65
i+1 12 7.5 2.11
i+2 6 10.3 0.85
... ... ... ...
n 8 12.6 4.2
The first question is how can I compute the n(n-1)/2 differences between Score i and Score j where i is from 1 to (n-1) and j is from (i+1) to n? I would then like R to spit out the differences in a file something like the following;
i j Difference
1 2 2
1 3 -4
... .. ...
(n-1) n D(n-1,n)
The second question is for each indexed sample from i to n, I would like to use something like rnorm(n, mean = 0, sd = 1) so that I could generate 1000 random draws from the distribution specified so that the arguments for rnorm () are as follows; mean = the value of Mean_Temp & sd = SD_Mean_Temp for indexed values i to n. I would, of course, then like R to spit out the massive table with 1000 columns of randomly generated temperature values for each index i to n.
Finally I would like to compute the slope estimator associated with the Theil statistic. All I need to do is compute the n(n-1)/n individual slope values; Sij = (Yj -Yi)/(Xj-Xi) where the Ys are the Scores for samples i to n and the Xs are the set of randomly generated temperature values, as before, 1 less than or equal to i less than j less than or equal to n. The median is then the estimator of Beta (the slope). I would like to compute the slopes for all 1000 sets of randomly generated temperature values.
i would greatly appreciate any help with these questions
Sincerely,
karsten G Holmquist
USDA-ARS-VCRU
More information about the R-help
mailing list