R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("regress-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('regress') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "regress" > > ### * regress > > flush(stderr()); flush(stdout()) > > ### Name: regress > ### Title: Fit a Gaussian Linear Model in which the Covariance Structure is > ### a Linear Combination of Known Matrices by Maximising the Residual Log > ### Likelihood > ### Aliases: regress > ### Keywords: regression models multivariate > > ### ** Examples > > ## Example of Random Effects model from Venables and Ripley, page 205 > library("nlme") > library("regress") > data(Oats) > names(Oats) <- c("B","V","N","Y") > Oats$N <- as.factor(Oats$N) > > ## Using regress > oats.reg <- regress(Y~N+V,~B+I(B:V),identity=TRUE,print.level=1,data=Oats) 1 732.1964 732.1964 732.1964 REML = -239.9202 2 214.4771 109.6929 162.5588 REML = -214.9749 3 214.4771 109.6929 162.5588 REML = -214.9749 > summary(oats.reg) Maximised Residual Log Likelihood is -214.975 Linear Coefficients: Estimate Std. Error (Intercept) 79.917 8.220 N0.2 19.500 4.250 N0.4 34.833 4.250 N0.6 44.000 4.250 VMarvellous 5.292 7.079 VVictory -6.875 7.079 Variance Coefficients: Estimate Std. Error B 214.477 168.834 I(B:V) 109.693 67.711 I 162.559 32.191 > > ## Using lme > oats.lme <- lme(Y~N+V,random=~1|B/V,data=Oats,method="REML") > summary(oats.lme) Linear mixed-effects model fit by REML Data: Oats AIC BIC logLik 586.0688 605.7756 -284.0344 Random effects: Formula: ~1 | B (Intercept) StdDev: 14.64549 Formula: ~1 | V %in% B (Intercept) Residual StdDev: 10.47060 12.75034 Fixed effects: Y ~ N + V Value Std.Error DF t-value p-value (Intercept) 79.91667 8.219989 51 9.722235 0.0000 N0.2 19.50000 4.250113 51 4.588114 0.0000 N0.4 34.83333 4.250113 51 8.195861 0.0000 N0.6 44.00000 4.250113 51 10.352667 0.0000 VMarvellous 5.29167 7.077578 10 0.747666 0.4719 VVictory -6.87500 7.077578 10 -0.971378 0.3543 Correlation: (Intr) N0.2 N0.4 N0.6 VMrvll N0.2 -0.259 N0.4 -0.259 0.500 N0.6 -0.259 0.500 0.500 VMarvellous -0.431 0.000 0.000 0.000 VVictory -0.431 0.000 0.000 0.000 0.500 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -1.84137227 -0.66274193 -0.06682795 0.63830229 1.66054158 Number of Observations: 72 Number of Groups: B V %in% B 6 18 > > > > ### *