Skip to content

sem package in R: a sample of transaction cost measurement


A sneak peek of the result of a Structural Equation Model using sem package in R.

I will present in the R User Conference in Warwick next week, is reveal first here.

The following are the codes of ‘sem’ package I used in the paper.

You may also view the code of other packages to run SEM models as well.

##-------------------------------------------------##
##    Measuring Transaction Cost in Supply Chains  ##
##               Pairach Piboonrungroj             ##
##         R useR conference August 2011           ##
##-------------------------------------------------##
install.packages("sem")
library(sem)

# 1. Load data
hoteldata <- read.csv("http://dl.dropbox.com/u/46344142/useR2011/cleandata.csv")

#Input covariance matrix
data.tc.1 <- cor(hoteldata)

# Have a look at the top of the data
# to check it we import the right one
head(data.tc.1)

#Create an object contains correlation matrix of the data for fitting the model in the next step
hotel.cor <- cor(hoteldata)
#  path parameter  start-value
model.TC.1 <- specify.model()
	TC   -> TC1,    gamma1,  NA # measurement item
	TC   -> TC2,    gamma2,  NA
 	TC   -> TC3,    gamma3,  NA
 	TC   -> TC6,    gamma6,  NA
 	TC   -> TC7,    gamma7,  NA
 	TC   -> TC11,   gamma11, NA
 	TC   -> TC13,   gamma13, NA
 	TC1  <-> TC1,	e1,      NA # measurement error
 	TC2  <-> TC2,	e2,      NA
 	TC3  <-> TC3,	e3,      NA
 	TC6  <-> TC6,	e6,      NA
 	TC7  <-> TC7,	e7,      NA
 	TC11 <-> TC11,	e11,     NA
 	TC13 <-> TC13,	e13,     NA
 	TC   <-> TC,    NA,      1

model.TC.1

sem.TC.1 <- sem(model.TC.1, data.tc.1, 53)
# print result (fit indices, parameters, hypothesis tests)
summary(sem.TC.1)
# standardised coefficients (loadings)
std.coef(sem.TC.1)
29 Comments Post a comment
  1. Heya i’m for the first time here. I came across this board and I find It really useful & it helped me out a lot. I hope to give something again and aid others such as you aided me.

    November 21, 2012
  2. Lorenz Books. Then sip on the tea slowly until it is gone.
    Grate enough fresh ginger to produce 2 tsp of ginger.

    Zielona Herbata

    June 23, 2013
  3. Magnificent items from you, man. I have take into account your stuff prior to and you
    are simply extremely wonderful. I really like what you have bought right here, really like
    what you’re stating and the way wherein you are saying
    it. You are making it entertaining and you still take care of to stay it sensible.
    I can’t wait to read much more from you. That is actually a tremendous website.

    June 8, 2014
  4. Nice blog right here! Additionally your site a lot up very fast!
    What host are you using? Can I get your associate link in your host?
    I want my site loaded up as quickly as yours lol

    June 9, 2014
  5. Howdy! Would you mind if I share your blog with my zynga group?
    There’s a lot of folks that I think would really appreciate your content.

    Please let me know. Thanks

    June 9, 2014
  6. I enjoy reading a post that can make people think.
    Also, thanks for permitting me to comment!

    June 21, 2014
  7. I have been browsing online more than 3 hourss today, yet I never found any iinteresting article lijke yours.

    It’s pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you
    did, the web will be a lot more useful than ever before.

    June 21, 2014
  8. Excellent post. Keep posting such kind oof info on your site.

    Im really impressed by your blog.
    Heloo there, You have performed an incredible job. I
    will definitely digg it and inn my opinion suggest to my
    friends. I’m sure they’ll be bebefited ffrom this site.

    July 1, 2014
  9. I am genuinely thankful to the holder of this web site who has shared this great piece
    of writing at at this time.

    July 1, 2014
  10. Consequently, there can be a restrict for the bandwidth that
    you would get. It is through an internet hosting service which enables you to get
    a good space around the server and also enables you to get legally
    registered by using it. This demand for the piece with the gold commodity is worldwide,
    so with such a limited amount, it is possible to see how that would drive the retail price up.

    July 5, 2014
  11. A similar rewards system is place for bandwidth.

    Quality web hosting service is very much necessary for the web page to operate properly.
    This promo code offers $25off on any hosting plans availed from hostgator.

    July 5, 2014
  12. Hey there! Someone in my Facebook group shared this website with us so I came to
    check it out. I’m definitely enjoying the
    information. I’m book-marking and will be tweeting this to
    my followers! Outstanding blog and excellent design and style.

    July 7, 2014
  13. I’m not sure where you’re getting your information, but great topic.

    I needs to spend some time learning more or understanding more.
    Thanks for magnificent information I was looking for
    this info for my mission.

    July 19, 2014
  14. I am actually thankful to the holder of this web site who has
    shared this wonderful article at at this time.

    July 21, 2014
  15. With havin so much content do you ever run into any issues
    of plagorism or copyright infringement? My
    site has a lot of completely unique content I’ve
    either written myself or outsourced but it seems a lot of it is popping it up all over the web without my agreement.
    Do you know any ways to help stop content from being stolen?
    I’d definitely appreciate it.

    July 29, 2014
  16. Hello, I think your website might be having browser compatibility issues.
    When I look at your website in Opera, it
    looks fine but when opening in Internet Explorer, it
    has some overlapping. I just wanted to give you a quick heads up!
    Other then that, very good blog!

    July 30, 2014
  17. I added half and half to my coffee in the 2nd week which is a major no, no
    on this diet and I stayed at the same weight for the week.
    B-12 injections – Vitamin B12 is known as the “energy vitamin” because it gives a real energy boost.
    It is released by the placenta when the fertilized egg is implanted in the
    uterus.

    August 3, 2014
  18. This blog was… how do you say it? Relevant!! Finally I have found something that helped me.
    Thanks!

    September 22, 2014
  19. I’ll immediately clutch your rrss feed as I can not to find
    your email subscription link or newsletter service.
    Do you have any? Please permit me know in order that I may just subscribe.
    Thanks. get more instagram followers fast

    October 1, 2014
  20. I am in fact delighted to read this web site posts which includes
    lots of valuable data, thanks for providing these kinds of information.

    October 1, 2014
  21. Piece of writing writing is also a excitement, if you be acquainted
    with then you can write or else it is complex to write.

    October 4, 2014
  22. If you want to get a great deal from this paragraph then you have to apply such strategies to your won web site.

    October 11, 2014
  23. Wonderful site. Lots of helpful information here.

    I’m sending it to several buddies ans also sharing in delicious.
    And certainly, thank you in your sweat!

    October 11, 2014
  24. Greetings from Ohio! I’m bored at work so I decided to browse
    your site on my iphone during lunch break. I really like the information you provide
    here and can’t wait to take a look when I get home.

    I’m amazed at how quick your blog loaded on my cell phone ..

    I’m not even using WIFI, just 3G .. Anyways, fantastic blog!

    December 10, 2014
  25. Excellent way of telling, and good piece of writing to
    get facts regarding my presentation focus, which i am going to deliver in college.

    December 20, 2014

Trackbacks & Pingbacks

  1. Data Analysis with R Training at Cardiff Bioscience – Day 1 | Pairach Piboonrungroj
  2. Data Analysis with R – Session 2 | Pairach Piboonrungroj
  3. R packages for Structural Equation Model | Pairach Piboonrungroj
  4. My presentation at The R useR! Conference 2011 | Pairach Piboonrungroj

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: