Syntax SPSS: How many respondents do I have?

SPSS: How many respondents do I have?

SPSS has many problems and one of them is that it rarely says how many respondents left after all these missing values in many variables in your analysis. I faced it when explaining MIXED command to the students who don’t like to get involve in other software. This is a really simple script that does only one thing – using LL, AIC and BIC indices (which, unlike sample size, are provided by many commands like MIXED) it computes the sample size. Additionally, it shows the number of parameters in the model that might be useful when comparing nested models. It is embedded into the interactive function, so the only thing you need to do, is to run it, enter BICtoSS(), copy and paste the whole “Information Criteria” table into the terminal and push ‘enter’. That’s it.


BICtoSS <-function(u) {
cat("Copy the 'Information Criteria' table from SPSS as it is, paste here and push 'Enter'")

a <- readLines(stdin(),n=11, ok = TRUE, warn = TRUE)
a1 <- read.delim(textConnection(a),header=FALSE,sep="\t",strip.white=TRUE)
BICnumber <- pmatch("Schwarz's Bayesian Criterion (BIC)", a1[,1])
LLnumber <- pmatch("-2 Log Likelihood", a1[,1])
AICnumber <- pmatch("Akaike's Information Criterion", a1[,1])
AIC <- a1[AICnumber,2]
BIC <- a1[BICnumber,2]
LL <- a1[LLnumber,2]

BICtoSSmanual <-function(AIC, BIC, LL) {
Npar <- (AIC - LL)/2
ss <- exp((BIC - LL)/Npar)
look<-list(SampleSize=ss, NumberOfParameters=Npar)
return (look)
}
result<-BICtoSSmanual(AIC, BIC, LL)
cat("The number of parameters is ", result$NumberOfParameters, "\n")
cat("The sample size is ", result$SampleSize)

}

 

https://maksimrudnev.com/r/