-
Notifications
You must be signed in to change notification settings - Fork 0
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
46bdae1
commit a6b7162
Showing
11 changed files
with
336 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,42 @@ | ||
CHANGES IN `modeltools' VERSION 0.2-3 | ||
|
||
CHANGES IN `modeltools' VERSION 0.2-2 | ||
o checkData does no longer insist that columns of a new data frame | ||
are in the same order as in the original data frame. | ||
|
||
o fxied a bug in the show() method for ModelEnv objects | ||
|
||
o remove special code for `Surv' objects in ParseFormula | ||
o new ModelEnv creator function ModelEnvMatrix | ||
|
||
o `linearModel@fit' now returns an object of class `linearModel' | ||
|
||
o `glinearModel' object added | ||
|
||
o S3 methods for (g)linearModel objects added (fitted, model.matrix, ...) | ||
|
||
|
||
CHANGES IN `modeltools' VERSION 0.2-0 | ||
CHANGES IN `modeltools' VERSION 0.2-2 | ||
|
||
|
||
o `Predict' checks for `StatModel' objects being available | ||
o remove special code for `Surv' objects in ParseFormula | ||
|
||
o `linearModel@fit' now returns an object of class `statmodel_lm' | ||
which inherits from `lm' and has its own `predict' method (in S3) | ||
|
||
o prepare for CRAN submission | ||
CHANGES IN `modeltools' VERSION 0.2-0 | ||
|
||
|
||
CHANGES IN `modeltools' VERSION 0.1-2 | ||
o `Predict' checks for `StatModel' objects being available | ||
|
||
o `linearModel@fit' now returns an object of class `statmodel_lm' | ||
which inherits from `lm' and has its own `predict' method (in S3) | ||
|
||
o `set' and `get' functions have an additional `envir' argument. This is | ||
now used by `clone', for example. | ||
o prepare for CRAN submission | ||
|
||
o lmfit now returns a `lm' object with element `predict_response' for | ||
computing predictions. | ||
|
||
CHANGES IN `modeltools' VERSION 0.1-2 | ||
|
||
|
||
o `set' and `get' functions have an additional `envir' argument. This is | ||
now used by `clone', for example. | ||
|
||
o lmfit now returns a `lm' object with element `predict_response' for | ||
computing predictions. | ||
|
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,12 +1,20 @@ | ||
|
||
import(methods) | ||
|
||
export(ModelEnvFormula, linearModel, Predict) | ||
export(ModelEnvFormula, ModelEnvMatrix, linearModel, glinearModel, Predict) | ||
|
||
exportClasses("ModelEnv", "FormulaParts", "ModelEnvFormula", "StatModel", | ||
"StatModelCapabilities") | ||
|
||
exportMethods("subset", "show", "dimension", "clone", "has", "initialize", | ||
"fit", "dpp", "na.omit", "na.fail", "na.pass", "subset") | ||
|
||
S3method(predict, statmodel_lm) | ||
S3method(fitted, glinearModel) | ||
S3method(fitted, linearModel) | ||
S3method(model.matrix, glinearModel) | ||
S3method(model.matrix, linearModel) | ||
S3method(predict, glinearModel) | ||
S3method(predict, linearModel) | ||
S3method(print, glinearModel) | ||
S3method(print, linearModel) | ||
S3method(weights, linearModel) |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
glinearModel <- new("StatModel", | ||
capabilities = new("StatModelCapabilities"), | ||
name = "generalized linear regression model", | ||
dpp = ModelEnvFormula, | ||
fit = function(object, weights = NULL, ...){ | ||
|
||
if (is.null(weights)) { | ||
z <- glm.fit(x = object@get("designMatrix"), | ||
y = object@get("response")[,1], | ||
intercept = all(object@get("designMatrix")[,1] == 1), | ||
...) | ||
} else { | ||
z <- glm.fit(x = object@get("designMatrix"), | ||
y = object@get("response")[,1], | ||
weights = weights, | ||
intercept = all(object@get("designMatrix")[,1] == 1), | ||
...) | ||
} | ||
class(z) <- c("glinearModel", "glm", "lm") | ||
z$offset <- 0 | ||
z$contrasts <- attr(object@get("designMatrix"), "contrasts") | ||
|
||
## terms should be there, but still need to | ||
## be worked around in predictions | ||
z$terms <- attr(object@get("input"), "terms") | ||
z$predict_response <- function(newdata = NULL) { | ||
if (!is.null(newdata)) { | ||
penv <- new.env() | ||
object@set("input", data = newdata, env = penv) | ||
dm <- get("designMatrix", envir = penv, inherits = FALSE) | ||
} else { | ||
dm <- object@get("designMatrix") | ||
} | ||
pr <- z$family$linkinv(drop(dm %*% z$coef)) | ||
return(pr) | ||
} | ||
z$addargs <- list(...) | ||
z$ModelEnv <- object | ||
z | ||
}, | ||
predict = function(object, newdata = NULL, ...) | ||
object$predict_response(newdata = newdata) | ||
) | ||
|
||
predict.glinearModel <- function(object, newdata = NULL, ...) | ||
object$predict_response(newdata = newdata) | ||
|
||
fitted.glinearModel <- function(object, ...) | ||
object$predict_response() | ||
|
||
print.glinearModel <- function(x, digits = max(3, getOption("digits") - 3), ...) | ||
{ | ||
fam <- x$family$family | ||
substr(fam, 1, 1) <- toupper(substr(fam, 1, 1)) | ||
cat(paste(fam, "GLM with coefficients:\n")) | ||
print.default(format(coef(x), digits = digits), print.gap = 2, quote = FALSE) | ||
invisible(x) | ||
} | ||
|
||
model.matrix.glinearModel <- function(object, ...) | ||
object$ModelEnv@get("designMatrix") |
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,27 +1,42 @@ | ||
CHANGES IN `modeltools' VERSION 0.2-3 | ||
|
||
CHANGES IN `modeltools' VERSION 0.2-2 | ||
o checkData does no longer insist that columns of a new data frame | ||
are in the same order as in the original data frame. | ||
|
||
o fxied a bug in the show() method for ModelEnv objects | ||
|
||
o remove special code for `Surv' objects in ParseFormula | ||
o new ModelEnv creator function ModelEnvMatrix | ||
|
||
o `linearModel@fit' now returns an object of class `linearModel' | ||
|
||
o `glinearModel' object added | ||
|
||
o S3 methods for (g)linearModel objects added (fitted, model.matrix, ...) | ||
|
||
|
||
CHANGES IN `modeltools' VERSION 0.2-0 | ||
CHANGES IN `modeltools' VERSION 0.2-2 | ||
|
||
|
||
o `Predict' checks for `StatModel' objects being available | ||
o remove special code for `Surv' objects in ParseFormula | ||
|
||
o `linearModel@fit' now returns an object of class `statmodel_lm' | ||
which inherits from `lm' and has its own `predict' method (in S3) | ||
|
||
o prepare for CRAN submission | ||
CHANGES IN `modeltools' VERSION 0.2-0 | ||
|
||
|
||
CHANGES IN `modeltools' VERSION 0.1-2 | ||
o `Predict' checks for `StatModel' objects being available | ||
|
||
o `linearModel@fit' now returns an object of class `statmodel_lm' | ||
which inherits from `lm' and has its own `predict' method (in S3) | ||
|
||
o `set' and `get' functions have an additional `envir' argument. This is | ||
now used by `clone', for example. | ||
o prepare for CRAN submission | ||
|
||
o lmfit now returns a `lm' object with element `predict_response' for | ||
computing predictions. | ||
|
||
CHANGES IN `modeltools' VERSION 0.1-2 | ||
|
||
|
||
o `set' and `get' functions have an additional `envir' argument. This is | ||
now used by `clone', for example. | ||
|
||
o lmfit now returns a `lm' object with element `predict_response' for | ||
computing predictions. | ||
|
Oops, something went wrong.