Hi, Statalist users.
I use Stata 14 SE and am working with a number of continuous variables measured across two waves from the same sample of individuals. I use mixed models and hence I often reshape my dataset into a long form.
The variables I use in my model (DV) are on different scales, and I wanted to rescale them all to range from 0 to 1.
I noticed that if I rescale before I reshape and if I rescale after I reshape, the model results differ, which I found quite puzzling.
The correlation of the original variables with their rescaled version ceases to be 1 in the long form.
I wonder if any of you may explain why that may be happening.
Given the difference in model outputs, which output should I trust?
I am leaning towards rescaling before reshaping.
This is the code I use to rescale:
I use Stata 14 SE and am working with a number of continuous variables measured across two waves from the same sample of individuals. I use mixed models and hence I often reshape my dataset into a long form.
The variables I use in my model (DV) are on different scales, and I wanted to rescale them all to range from 0 to 1.
I noticed that if I rescale before I reshape and if I rescale after I reshape, the model results differ, which I found quite puzzling.
The correlation of the original variables with their rescaled version ceases to be 1 in the long form.
I wonder if any of you may explain why that may be happening.
Given the difference in model outputs, which output should I trust?
I am leaning towards rescaling before reshaping.
This is the code I use to rescale:
Code:
foreach var of varlist x_w1 x_w2 y_w1 y_w2 z_w1 z_w3 { egen min`var'=min(`var') egen max`var'=max(`var') gen `var'_01= ((`var'-min`var')/(max`var'-min`var'))
Comment