2017年5月7日星期日

Create an empty list and flatten the list

x<-c(2.3,0.3,5.2,3.1,1.1,0.9,2.0,0.7,1.4,0.3)
y<-c(0.8,2.8,4.0,2.4,1.2,0.0,6.2,1.5,28.8,0.7)

L<-vector("list",10)

for(i in 1:10){

L[[i]]<-y[i]-x #key is [[]] operator here
}

d<-unlist(L)
median(d)  # This is Hodges-Lehmann estimator

2017年5月5日星期五

Hodges-Lehmann Estimation of Location Shift



data e1041;
input group $ x;
datalines;
1 2.3
1 0.3
1 5.2
1 3.1
1 1.1
1 0.9
1 2.0
1 0.7
1 1.4
1 0.3
2 0.8
2 2.8
2 4.0
2 2.4
2 1.2
2 0.0
2 6.2
2 1.5
2 28.8
2 0.7
;
run;
 proc npar1way hl alpha=.05 data=e1041;
      class group;
      var x;
      exact hl;
      ods select WilcoxonScores HodgesLehmann;
  run;




2017年5月2日星期二

linear vs nolinear


A regression model is called nonlinear, if the derivatives of the model with respect to the model parameters depends on one or more parameters. This definition is essential to distinguish nonlinear from curvilinear regression. A regression model is not necessarily nonlinear if the graphed regression trend is curved. A polynomial model such as y = b0 + b1x + b2x2 + e appears curved when y is plotted against x. It is, however, not a nonlinear model. To see this, take derivatives of y with respect to the parameters b0b1, and b2: dy/db0 = 1, dy/db1 = x, dy/db2 = x2 None of these derivatives depends on a model parameter, the model is linear. In contrast, consider the log-logistic model y = d + (a - d)/(1 + exp{b log(x/g)}) + e Take derivatives with respect to d, for example: dy/dd = 1 - 1/(1 + exp{b log(x/g)}). The derivative involves other parameters, hence the model is nonlinear

.http://www.ats.ucla.edu/stat/sas/library/SASNLin_os.htm

Like Father Like Son


2017年4月27日星期四

The idea of utility -a very interesting explanation

https://stats.stackexchange.com/a/276376/61705

"The idea of utility is very simple. It converts the numerical outcome into the utility to you. Say, you get 10 apples or 5 oranges, or some combination of two. How would you compare apples to oranges? Easy, I offer you to take either of two choices, and you pick one. So, theory goes that there's some kind of a function 
U(x1,x2,,xn) such that when you feed it a basket of goods 1,2,,n with quantities xi of each good, this function returns a scalar value, which reflects the utility of this basket to you. You pick the one with a greater utility.
So, if I feed it U(10,0) or U(0,5), where the good 1 is apples, and the good 2 is oranges, it'll return two different numbers, the greater one will indicate which basket has more utility to you. YOu can combine goods in the same basket U(1,1) - one apple and one orange.
So, in a nutshell, the utility function is a concept that allows us to compare apples to oranges. The theory states that you pcik the baskets based on their utility, which is calculated by plugging the basket descriptions into this utility function."