From 72dca7bf2a27c0928edd0b9bb4659ee46f9f0f12 Mon Sep 17 00:00:00 2001 From: Benjamin Hofner Date: Tue, 22 Dec 2015 18:41:43 +0100 Subject: [PATCH] Don't use symlinks in tests/birds_Biometrics.R --- pkg/mboostDevel/tests/birds_Biometrics.R | 99 +++++++++++++++++++++++- pkg/mboostPatch/tests/birds_Biometrics.R | 99 +++++++++++++++++++++++- 2 files changed, 196 insertions(+), 2 deletions(-) mode change 120000 => 100644 pkg/mboostDevel/tests/birds_Biometrics.R mode change 120000 => 100644 pkg/mboostPatch/tests/birds_Biometrics.R diff --git a/pkg/mboostDevel/tests/birds_Biometrics.R b/pkg/mboostDevel/tests/birds_Biometrics.R deleted file mode 120000 index c6ff9dc..0000000 --- a/pkg/mboostDevel/tests/birds_Biometrics.R +++ /dev/null @@ -1 +0,0 @@ -../inst/birds_Biometrics.R \ No newline at end of file diff --git a/pkg/mboostDevel/tests/birds_Biometrics.R b/pkg/mboostDevel/tests/birds_Biometrics.R new file mode 100644 index 0000000..5613749 --- /dev/null +++ b/pkg/mboostDevel/tests/birds_Biometrics.R @@ -0,0 +1,98 @@ + +library("mboostDevel") +data("birds", package = "TH.data") + +# define characteristics of the boosting algorithm +bcr <- boost_control(mstop=200, trace=TRUE) + +# estimation of a purely linear GLM +fm <- SG5 ~ bols(GST) + bols(DBH) + bols(AOT) + bols(AFS) + bols(DWC) + + bols(LOG) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) + +# extract and plot AIC curve against iteration index and determine stopping +# iteration +birdsaic <- AIC(sp, "classical") +plot(birdsaic) +ms <- mstop(birdsaic) + +# selection frequencies of the model terms +table(sp$xselect()[1:ms]) + +# estimated coefficients +coef(sp[ms]) + +# re-define boosting iterations +bcr <- boost_control(mstop=500, trace=TRUE) + +# Variable selection in a GLM without spatial component +fm <- SG4 ~ bols(GST) + bols(DBH) + bols(AOT) + bols(AFS) + bols(DWC) + + bols(LOG) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +table(sp$xselect()) +coef(sp, which=1:6) + +# Variable selection in a GLM with high df spatial component +fm <- SG4 ~ bols(GST) + bols(DBH) + bols(AOT) + bols(AFS) + bols(DWC) + + bols(LOG) + bspatial(x_gk, y_gk, df=5, differences=1, knots=c(12,12)) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +table(sp$xselect()) +coef(sp, which=1:6) + +# Variable selection in a GLM with small df spatial component +fm <- SG4 ~ bols(GST) + bols(DBH) + bols(AOT) + bols(AFS) + bols(DWC) + + bols(LOG) + bspatial(x_gk, y_gk, df=1, differences=1, knots=c(12,12), center=TRUE) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +table(sp$xselect()) +coef(sp, which=1:6) + + +# Geoadditive regression model without centering +fm <- SG5 ~ bbs(GST) + bbs(DBH) + bbs(AOT) + bbs(AFS) + bbs(DWC) + + bbs(LOG) + bspatial(x_gk, y_gk, df=4, differences=1, knots=c(12,12)) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +plot(sp) + +# Geoadditive regression model with centering + +fm <- SG5 ~ bols(GST) + bbs(GST, df=1, center=TRUE) + + bols(AOT) + bbs(AOT, df=1, center=TRUE) + + bols(AFS) + bbs(AFS, df=1, center=TRUE) + + bols(DWC) + bbs(DWC, df=1, center=TRUE) + + bols(LOG) + bbs(LOG, df=1, center=TRUE) + + bspatial(x_gk, y_gk, df=1, differences=1, knots=c(12,12), + center=TRUE) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +plot(sp) + + +# re-define boosting iterations +bcr <- boost_control(mstop=200, trace=TRUE) + +# transform covariates to [0,1] +birds$GST <- (birds$GST-min(birds$GST))/(max(birds$GST)-min(birds$GST)) +birds$AOT <- (birds$AOT-min(birds$AOT))/(max(birds$AOT)-min(birds$AOT)) +birds$AFS <- (birds$AFS-min(birds$AFS))/(max(birds$AFS)-min(birds$AFS)) +birds$DWC <- (birds$DWC-min(birds$DWC))/(max(birds$DWC)-min(birds$DWC)) +birds$LOG <- (birds$LOG-min(birds$LOG))/(max(birds$LOG)-min(birds$LOG)) + +# Space-varying coefficient models (with centered spatial effects) +fm <- SG5 ~ bols(GST) + bspatial(x_gk, y_gk, by = GST, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bols(AOT) + bspatial(x_gk, y_gk, by = AOT, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bols(AFS) + bspatial(x_gk, y_gk, by = AFS, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bols(DWC) + bspatial(x_gk, y_gk, by = DWC, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bols(LOG) + bspatial(x_gk, y_gk, by = LOG, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bspatial(x_gk, y_gk, df=1, differences=1, knots=c(12, 12), + center=TRUE) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +plot(sp, which = "GST") +plot(sp, which = "AOT") +plot(sp, which = "AFS") +plot(sp, which = "DWC") +plot(sp, which = "LOG") + diff --git a/pkg/mboostPatch/tests/birds_Biometrics.R b/pkg/mboostPatch/tests/birds_Biometrics.R deleted file mode 120000 index c6ff9dc..0000000 --- a/pkg/mboostPatch/tests/birds_Biometrics.R +++ /dev/null @@ -1 +0,0 @@ -../inst/birds_Biometrics.R \ No newline at end of file diff --git a/pkg/mboostPatch/tests/birds_Biometrics.R b/pkg/mboostPatch/tests/birds_Biometrics.R new file mode 100644 index 0000000..29e3d35 --- /dev/null +++ b/pkg/mboostPatch/tests/birds_Biometrics.R @@ -0,0 +1,98 @@ + +library("mboost") +data("birds", package = "TH.data") + +# define characteristics of the boosting algorithm +bcr <- boost_control(mstop=200, trace=TRUE) + +# estimation of a purely linear GLM +fm <- SG5 ~ bols(GST) + bols(DBH) + bols(AOT) + bols(AFS) + bols(DWC) + + bols(LOG) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) + +# extract and plot AIC curve against iteration index and determine stopping +# iteration +birdsaic <- AIC(sp, "classical") +plot(birdsaic) +ms <- mstop(birdsaic) + +# selection frequencies of the model terms +table(sp$xselect()[1:ms]) + +# estimated coefficients +coef(sp[ms]) + +# re-define boosting iterations +bcr <- boost_control(mstop=500, trace=TRUE) + +# Variable selection in a GLM without spatial component +fm <- SG4 ~ bols(GST) + bols(DBH) + bols(AOT) + bols(AFS) + bols(DWC) + + bols(LOG) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +table(sp$xselect()) +coef(sp, which=1:6) + +# Variable selection in a GLM with high df spatial component +fm <- SG4 ~ bols(GST) + bols(DBH) + bols(AOT) + bols(AFS) + bols(DWC) + + bols(LOG) + bspatial(x_gk, y_gk, df=5, differences=1, knots=c(12,12)) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +table(sp$xselect()) +coef(sp, which=1:6) + +# Variable selection in a GLM with small df spatial component +fm <- SG4 ~ bols(GST) + bols(DBH) + bols(AOT) + bols(AFS) + bols(DWC) + + bols(LOG) + bspatial(x_gk, y_gk, df=1, differences=1, knots=c(12,12), center=TRUE) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +table(sp$xselect()) +coef(sp, which=1:6) + + +# Geoadditive regression model without centering +fm <- SG5 ~ bbs(GST) + bbs(DBH) + bbs(AOT) + bbs(AFS) + bbs(DWC) + + bbs(LOG) + bspatial(x_gk, y_gk, df=4, differences=1, knots=c(12,12)) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +plot(sp) + +# Geoadditive regression model with centering + +fm <- SG5 ~ bols(GST) + bbs(GST, df=1, center=TRUE) + + bols(AOT) + bbs(AOT, df=1, center=TRUE) + + bols(AFS) + bbs(AFS, df=1, center=TRUE) + + bols(DWC) + bbs(DWC, df=1, center=TRUE) + + bols(LOG) + bbs(LOG, df=1, center=TRUE) + + bspatial(x_gk, y_gk, df=1, differences=1, knots=c(12,12), + center=TRUE) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +plot(sp) + + +# re-define boosting iterations +bcr <- boost_control(mstop=200, trace=TRUE) + +# transform covariates to [0,1] +birds$GST <- (birds$GST-min(birds$GST))/(max(birds$GST)-min(birds$GST)) +birds$AOT <- (birds$AOT-min(birds$AOT))/(max(birds$AOT)-min(birds$AOT)) +birds$AFS <- (birds$AFS-min(birds$AFS))/(max(birds$AFS)-min(birds$AFS)) +birds$DWC <- (birds$DWC-min(birds$DWC))/(max(birds$DWC)-min(birds$DWC)) +birds$LOG <- (birds$LOG-min(birds$LOG))/(max(birds$LOG)-min(birds$LOG)) + +# Space-varying coefficient models (with centered spatial effects) +fm <- SG5 ~ bols(GST) + bspatial(x_gk, y_gk, by = GST, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bols(AOT) + bspatial(x_gk, y_gk, by = AOT, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bols(AFS) + bspatial(x_gk, y_gk, by = AFS, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bols(DWC) + bspatial(x_gk, y_gk, by = DWC, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bols(LOG) + bspatial(x_gk, y_gk, by = LOG, df=1, differences=1, + knots=c(12, 12), center=TRUE) + + bspatial(x_gk, y_gk, df=1, differences=1, knots=c(12, 12), + center=TRUE) +sp <- gamboost(fm, data = birds, family = Poisson(), control = bcr) +plot(sp, which = "GST") +plot(sp, which = "AOT") +plot(sp, which = "AFS") +plot(sp, which = "DWC") +plot(sp, which = "LOG") +