Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c1baa3
commit e0e8cbf
Showing
4 changed files
with
23 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
## stepAIC on an lme object: an example from Robert Cuffe | ||
library(nlme) | ||
library(MASS) | ||
set.seed(321) # to be sure | ||
a <- data.frame( resp=rnorm(250), cov1=rnorm(250), | ||
cov2=rnorm(250), group=rep(letters[1:10],25) ) | ||
mod1 <- lme(resp~cov1, a, ~cov1|group, method="ML") | ||
mod2 <- stepAIC(mod1, scope=list(upper=~(cov1+cov2)^2, lower=~1) ) | ||
if(require(nlme)) { | ||
library(MASS) | ||
set.seed(321) # to be sure | ||
a <- data.frame( resp=rnorm(250), cov1=rnorm(250), | ||
cov2=rnorm(250), group=rep(letters[1:10],25) ) | ||
mod1 <- lme(resp~cov1, a, ~cov1|group, method="ML") | ||
mod2 <- stepAIC(mod1, scope=list(upper=~(cov1+cov2)^2, lower=~1) ) | ||
|
||
beav <- beav2 | ||
set.seed(123) | ||
beav$dummy <- rnorm(nrow(beav)) | ||
beav.gls <- gls(temp ~ activ + dummy, data = beav, | ||
corr = corAR1(0.8), method = "ML") | ||
stepAIC(beav.gls) | ||
beav <- beav2 | ||
set.seed(123) | ||
beav$dummy <- rnorm(nrow(beav)) | ||
beav.gls <- gls(temp ~ activ + dummy, data = beav, | ||
corr = corAR1(0.8), method = "ML") | ||
stepAIC(beav.gls) | ||
} | ||
|