File: testgFit.R

package info (click to toggle)
r-cran-dosefinding 0.9-17-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 612 kB
  • sloc: ansic: 507; sh: 21; makefile: 2
file content (99 lines) | stat: -rw-r--r-- 4,539 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
require("DoseFinding")
data(IBScovars)
lmfit <- lm(resp~factor(dose)+gender, data=IBScovars)
cf <- coef(lmfit)[-c(6)]
vcv <- vcov(lmfit)[-c(6), -c(6)]
lmfit2 <- lm(resp~as.factor(dose)-1+gender, data=IBScovars)
cf2 <- coef(lmfit2)[-c(6)]
vcv2 <- vcov(lmfit2)[-c(6), -c(6)]
dose <- c(0:4)

## test fitting all available models
fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="linear", placAdj=TRUE,type="general")
fitMod(dose, cf2, S=vcv2, model="linear", placAdj=FALSE,type="general")
fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="quadratic", placAdj=TRUE,type="general")
fitMod(dose, cf2, S=vcv2, model="quadratic", placAdj=FALSE,type="general")
fitMod(dose, cf2, S=vcv2, model="linlog", placAdj=FALSE,
       addArgs=list(off=0.01*max(dose)),type="general")
fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="emax", placAdj=TRUE,
       bnds=defBnds(max(dose))$emax,type="general")
fitMod(dose, cf2, S=vcv2, model="emax", placAdj=FALSE,
       bnds=defBnds(max(dose))$emax,type="general")
fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="sigEmax", placAdj=TRUE,
       bnds=defBnds(max(dose))$sigEmax,type="general")
fitMod(dose, cf2, S=vcv2, model="sigEmax", placAdj=FALSE,
       bnds=defBnds(max(dose))$sigEmax,type="general")
fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="exponential",
       placAdj=TRUE, bnds=defBnds(max(dose))$exponential,type="general")
fitMod(dose, cf2, S=vcv2, model="exponential", placAdj=FALSE,
       bnds=defBnds(max(dose))$exponential,type="general")
fitMod(dose, cf2, S=vcv2, model="logistic", placAdj=FALSE,
       bnds=defBnds(max(dose))$logistic,type="general")
fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="betaMod", placAdj=TRUE,
       bnds=defBnds(max(dose))$betaMod, addArgs=list(scal=1.2*4),type="general")
fitMod(dose, cf2, S=vcv2, model="betaMod", placAdj=FALSE,
       bnds=defBnds(max(dose))$betaMod, addArgs=list(scal=1.2*4),type="general")
fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="linInt", placAdj=TRUE, type="general")
fitMod(dose, cf2, S=vcv2, model="linInt", placAdj=FALSE, type="general")
## test using starting value (instead of grid search)
fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="emax",
       placAdj=TRUE, bnds=defBnds(max(dose))$emax, start = 0.5,type="general")
fitMod(dose, cf2, S=vcv2, model="emax", placAdj=FALSE,
       bnds=defBnds(max(dose))$emax, start = 0.2,type="general")
fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="betaMod",
       placAdj=TRUE, bnds=defBnds(max(dose))$betaMod,
       addArgs=list(scal=1.2*4),type="general")
fitMod(dose, cf2, S=vcv2, model="betaMod", placAdj=FALSE,
       bnds=defBnds(max(dose))$betaMod, start = c(1, 1),
       addArgs=list(scal=1.2*4),type="general")

## test predict, vcov, coef, intervals, plot, summary
ggI <- fitMod(dose, cf2, S=vcv2, model="betaMod",
              placAdj=FALSE, bnds=defBnds(max(dose))$betaMod,
              addArgs=list(scal=1.2*4),type="general")
ggNI <- fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="betaMod",
               placAdj=TRUE, bnds=defBnds(max(dose))$betaMod,
               addArgs=list(scal=1.2*4),type="general")
predict(ggI, se.fit=TRUE, predType = "e")
predict(ggNI, se.fit=TRUE, predType = "e")
vcov(ggI)
vcov(ggNI)
plot(ggI, CI=T, plotData = "meansCI")
plot(ggNI, CI=T, plotData = "meansCI")

ggI <- fitMod(dose, cf2, S=vcv2, model="linInt",
              placAdj=FALSE,type="general")
ggNI <- fitMod(dose[-1], cf[-1], S=vcv[-1,-1], model="linInt",
               placAdj=TRUE,type="general")
predict(ggI, se.fit=TRUE, predType = "full-model")
predict(ggI, se.fit=TRUE, predType = "effect-curve")
predict(ggNI, se.fit=TRUE, predType = "full-model")
vcov(ggI)
vcov(ggNI)
plot(ggI, CI=T, plotData = "meansCI")
plot(ggNI, CI=T, plotData = "meansCI")

## even more tests for the linInt model
data(IBScovars)
## without covariates
fit <- fitMod(dose, resp, data=IBScovars, model="linInt")
plot(fit, CI=TRUE, plotData="meansCI")
fit <- fitMod(dose, resp, data=IBScovars, model="linInt",
                  addCovars=~gender)
plot(fit, CI=TRUE, plotData="meansCI")
vcov(fit)
fit <- lm(resp~as.factor(dose)-1, data=IBScovars)
cf <- coef(fit)
vc <- vcov(fit)
doseVec <- 0:4
fit <- fitMod(doseVec, cf, model="linInt", S=vc, type = "general")
plot(fit, CI=TRUE, plotData="meansCI")
vcov(fit)
fit <- lm(resp~as.factor(dose)+gender, data=IBScovars)
cf <- coef(fit)[2:5]
vc <- vcov(fit)[2:5,2:5]
doseVec <- 1:4
fit <- fitMod(doseVec, cf, model="linInt", S=vc, type = "general", placAdj=TRUE)
vcov(fit)
plot(fit, CI=TRUE, plotData="meansCI")
predict(fit, predType = "effect-curve", se.fit=TRUE)