Stat 6601 Project: Model Formulae V - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Stat 6601 Project: Model Formulae V

Description:

drug = factor(rep(c('placebo','ritalin'),each=4,times=2)), subj = factor(rep(1:4,4) ... Column 2 -- Drug (Placebo, Ritalin) # Column 3 -- Subject (1-4) ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 16
Provided by: sciCsuh
Category:

less

Transcript and Presenter's Notes

Title: Stat 6601 Project: Model Formulae V


1
Stat 6601 ProjectModel Formulae (VR 6.2)
Antonio Curtis Wai Mak Alvin Hsieh Statistics
Students, CSUH
2
Model
Multiple Regression Formula
Algebraic Expression
3
Data
Working Directory R - FilegtChange dirgtClick
BrowsegtSelect DesktopgtClick OK SAS - where
your program resides (.sas)
reading.txt Group Words Group Words Group Words
X 700 Y 480 Z 500 X 850 Y 460 Z 550 X 820 Y 500 Z
480 X 640 Y 570 Z 600 X 920 Y 580 Z 610
4
R Program - Reading
reading lt- read.table("data/reading.txt",sep'
', col.namesc('group','words')) obj lt-
lm(words group, reading) anova(obj)
5
SAS Program - Reading
data reading infile "./data/reading.txt"
input group words _at__at_ proc anova datareading
title 'Analysis of Reading Data' class
group model words group run
6
Interaction
  • More than one independent variable
  • Relationship with independent variables
  • R code
  • y a b ab
  • y (a b)2
  • y a b
  • SAS code
  • y a b
  • y a b ab

7
Data
ritalin.txt 50 45 55 52 67 60 58 65 70 72 68 75
51 57 48 55
8
R Program - Ritalin
ritalin lt- data.frame(group factor(rep(c('normal
','hyper'),each8)), drug
factor(rep(c('placebo','ritalin'),each4,times2
)), subj
factor(rep(14,4)), activity
factor(t(read.table("data/ritalin.txt",sep'
')))) ritalinactivity lt- as.numeric(ritalinactiv
ity) names(ritalin) attach(ritalin) Column 1 --
Group (Normal or Hyperactive) Column 2 -- Drug
(Placebo, Ritalin) Column 3 -- Subject (1-4)
Column 4 -- Activity (Activity measurement) obj
lt- lm(activity group drug) obj anova(obj)
9
SAS Program - Ritalin
data ritalin infile "./data/ritalin.txt"
do group 'normal','hyper ' do drug
'placebo','ritalin' do subj 1 to 4
input activity _at_ output
end end end run proc anova
dataritalin title 'Activity Study' class
group drug model activity group drug run
10
Difference R and SAS
  • Reading in Data
  • Defining variables
  • Invoking commands
  • Lines of codes
  • Learning curve

11
Summary
  • Model - General form
  • Interaction
  • R example
  • SAS example
  • Differences in R and SAS

12
Reference
  • Applied Statistics and SAS Programming Language
    (4th ed) by Ronald P. Cody and Jeffrey K. Smith,
    Prentice-Hall, Inc., 1997
  • Modern Applied Statistics with S (4th ed) by W.N.
    Venables and B.D. Ripley, Springer-Verlag New
    York, Inc.,2002

13
Thank You!
Any Questions? Have a nice day!
14
(No Transcript)
15
Extra - Contrasts
  • 4 supplied contrast functions
  • contr.helmert (default) - unordered factors
  • contr.treatment - omitting level 1 (?10)
  • Unbalanced layouts (GLM and survival models)
  • contr.sum - coefficients add to 0 (??0)
  • contr.poly (default - ordered) - equally spaced,
    equally replicated

Code to specify contrasts options(contrasts
c(contr.helmert,contr.poly))
Write a Comment
User Comments (0)
About PowerShow.com