1 / 15

Stat 6601 Project: Model Formulae (V&R 6.2)

Stat 6601 Project: Model Formulae (V&R 6.2). Antonio Curtis Wai Mak Alvin Hsieh Statistics Students, CSUH. Model. where,. Multiple Regression Formula. Algebraic Expression. Data. Working Directory R - File>Change dir…>Click Browse>Select Desktop>Click OK

eithne
Download Presentation

Stat 6601 Project: Model Formulae (V&R 6.2)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Stat 6601 Project:Model Formulae (V&R 6.2) Antonio Curtis Wai Mak Alvin Hsieh Statistics Students, CSUH

  2. Model where, Multiple Regression Formula Algebraic Expression

  3. Data Working Directory R - File>Change dir…>Click Browse>Select Desktop>Click 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 <- read.table("data/reading.txt",sep=' ', col.names=c('group','words')) obj <- lm(words ~ group, reading) anova(obj)

  5. SAS Program - Reading data reading; infile "./data/reading.txt"; input group $ words @@; proc anova data=reading; 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 + a:b • y ~ (a + b)^2 • y ~ a * b • SAS code • y = a | b • y = a b a*b

  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 <- data.frame(group = factor(rep(c('normal','hyper'),each=8)), drug = factor(rep(c('placebo','ritalin'),each=4,times=2)), subj = factor(rep(1:4,4)), activity = factor(t(read.table("data/ritalin.txt",sep=' ')))) ritalin$activity <- as.numeric(ritalin$activity) 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 <- 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 @; output; end; end; end; run; procanova data=ritalin; 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. Extra - Contrasts • 4 supplied contrast functions: • contr.helmert (default) - unordered factors • contr.treatment - omitting level 1 (1=0) • 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”))

More Related