### This code shows how to obtain a z-score (see also Analyze->Descriptives group), and how
### to convert it to T-scores, scale scores, standard scores, etc.

#Convert LifeSat to a zscore

#Zscore: mean of 0, sd of 1
Wk07a$ZLifeSat<-scale(Wk07a$LifeSat, center=TRUE, scale=TRUE)

#Tscore: mean of 50, sd of 10
Wk07a$TLifeSat<- ((Wk07a$ZLifeSat * 10) + 50)

#Standard score: mean of 100, sd of 15 (IQ)
Wk07a$STLifeSat<- ((Wk07a$ZLifeSat * 15) + 100)

#Scale score: mean of 10, sd of 3 (many NP tests)
Wk07a$SCLifeSat<- ((Wk07a$ZLifeSat * 3) + 10)

#SAT/GRE score (old): mean of 500, sd of 100
Wk07a$SATLifeSat<- ((Wk07a$ZLifeSat * 100) + 500)


#Longitudinal standardization
#To preserve change information in longitudinal standardization, you need to standardize by formula,
#using the BASELINE mean and standard deviation as your standardization base.

#CORRECT WAY FOR LONGITUDINAL STANDARDIZATION!!!!!!!!!!!!!
#Baseline Memory and Life Satisfaction were standardized using psych::scale
#But occasion 2 Memory and Life Satisfaction are standardized as below
Wk07a$ZLifeSat2_correct<- (Wk07a$LifeSat2-mean(Wk07a$LifeSat))/sd(Wk07a$LifeSat)
Wk07a$ZMemory2_correct<- (Wk07a$Memory2-mean(Wk07a$Memory))/sd(Wk07a$Memory)

psych::describe(Wk07a[,c(2,16,14,17)])
##                   vars   n mean   sd median trimmed  mad   min  max range  skew
## ZLifeSat 1 182 0.00 1.00 0.10 0.03 0.95 -2.25 2.69 4.95 -0.19
## ZLifeSat2_correct 2 182 0.56 1.03 0.59 0.58 1.06 -1.80 3.14 4.94 -0.10
## ZMemory 3 182 0.00 1.00 0.03 0.02 1.03 -2.28 2.51 4.79 -0.10
## ZMemory2_correct 4 182 0.98 1.13 1.02 0.98 1.23 -2.74 4.33 7.07 -0.08
## kurtosis se
## ZLifeSat -0.45 0.07
## ZLifeSat2_correct -0.59 0.08
## ZMemory -0.59 0.07
## ZMemory2_correct 0.29 0.08