Blog Archives

Life Satisfaction: Motion Chart in googleVis

August 27, 2012
By
Life Satisfaction: Motion Chart in googleVis

This is a motion chart I created using the life and life domain satisfaction data from the 2003 longitudinal study of Australian young people. The satisfaction measures cover the ages 16 to 22. [cf]Satisfaction Chart[/cf]  

Read more »

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

March 16, 2011
By
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 #http://preprints.stat.ucla.edu/260/chisquare.pdf # This function provides scaled differences tests based on … Continue reading →

Read more »

Collider Example

February 24, 2011
By
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 inside-R.org

Read more »

Stirling’s formula for R

February 1, 2011
By
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 inside-R.org

Read more »

Pseudo R Square Values in R

January 26, 2011
By
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 →

Read more »

Additional Functions for the MatchIt Package – Part 2

November 13, 2010
By
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 →

Read more »

Simplified Output for Matchit package

November 2, 2010
By
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 →

Read more »

Displaying K-means Results.

October 22, 2010
By
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 →

Read more »

Creating Composite Scores in R

October 13, 2010
By
Creating Composite Scores in R

There maybe times when you need scores corrected for measurement error and latent factor loading. In these instances it can be beneficial to use  composite scores derived from one factor congeneric models. While easy they are time consuming to calculate by hand … Continue reading →

Read more »

Corrected Cohen’s D

October 13, 2010
By
Corrected Cohen’s D

Calculating Cohen’s D is a pain particularly when you have data which is not independent (e.g. is longitudinal). So I have written a function which take away the hassle. It is in early form but produces a normal Cohen’s D and … Continue reading →

Read more »


Subscribe

Email:

  Subscribe