Author Archives: Philip Parker

About Philip Parker

I am a post doc in developmental and educational psychology at a Germany university. I did my PhD at the university of Sydney in stress and well-being. Most days I am hunched over a computer yelling at statistical software or responding to journal editors who seem to always want twice the amount of content but with half the words. For fun I like to read up on the latest developments in R and programming various functions.

Function for Scaled Difference Tests (chi-square and logliklihood values)

#For use when comparing the fit of nested models with complex data, # (e.g. TYPE = COMPLEX is mplus) # The Scaled Difference Chi-square Test Statistic can be found at # # This function provides scaled differences tests based on … Continue reading

Posted in Uncategorized | Leave a comment

Collider Example

library (MASS) covar<-mvrnorm(250, c(0, 0), matrix(c(1, 0.00, 0.00, 1), 2, 2)) mydata<-data.frame(covar) names(mydata)<-c("sat", "mot") mydata$admin<- mydata$sat + mydata$mot mydata$admin2<- ifelse (mydata$admin >=quantile(mydata$admin, .85), "pass", "fail")   library(ggplot2) qplot(sat,mot, data = mydata, color = admin2) Created by Pretty R at

Posted in Uncategorized | Leave a comment

Stirling’s formula for R

I am sure it is out there but for my record keeping purposes and for anyone interested here is a quick function to find Stirling’s approximation of all possible permutations Stirling<- function (n)((2*pi*n)^.5)*(n/exp(1))^n Created by Pretty R at

Posted in Uncategorized | 1 Comment

Pseudo R Square Values in R

R does not give a Pseudo R square value and neither does Mplus. As such, here is a real quick R function to calculate McFadden’s and Adjusted McFadden’s Pseudo R square value:   #Pesudo R square #x = full model … Continue reading

Posted in Uncategorized | 2 Comments

Additional Functions for the MatchIt Package – Part 2

I have reworked the graphing and summarizing functions I wrote for the matchit package to be cleaner and to provide more information. Currently I have functions for a sorted by size summary table of the post matching mean differences: meandifftable<- … Continue reading

Posted in Uncategorized | Leave a comment

Simplified Output for Matchit package

Have been attending a seminar on propensity score matching this week, when I was asked if I could write a function to reduce the complexity of the matchit package output. I produced two functions. First I wrote a function to … Continue reading

Posted in Uncategorized | Leave a comment

Displaying K-means Results.

I am a fan of K-means approaches to clustering data particularly when you have a theoretical reason to expect a certain number of clusters and you have a large data set. However, I think ploting the cluster means can be … Continue reading

Posted in Uncategorized | 1 Comment