Hi, I am reading and learning from a tutorial on Rasch model.
Within, there is a function to adjust covariates.
functions {
matrix obtain_adjustments(matrix W) {
real min_w;
real max_w;
int minmax_count;
matrix[2, cols(W)] adj;
adj[1, 1] = 0;
adj[2, 1] = 1;
if(cols(W) > 1) {
for(k in 2:cols(W)) { // remaining columns
min_w = min(W[1:rows(W), k]);
max_w = max(W[1:rows(W), k]);
minmax_count = 0;
for(j in 1:rows(W))
minmax_count = minmax_count + W[j,k] == min_w || W[j,k] == max_w;
if(minmax_count == rows(W)) { // if column takes only 2 values
adj[1, k] = mean(W[1:rows(W), k]);
adj[2, k] = (max_w - min_w);
} else { // if column takes > 2 values
adj[1, k] = mean(W[1:rows(W), k]);
adj[2, k] = sd(W[1:rows(W), k]) * 2;
}
}
}
return adj;
}
}
The tutorial provides an explanation on what is going on. But I am baffled by one line:
adj[2, k] = sd(W[1:rows(W), k]) * 2;
My understanding is that this line calculates the standard deviation and then later is used in the denominator for standardization. But how come it is SD*2?
Thank you.