search for: addterm

Displaying 20 results from an estimated 33 matches for "addterm".

Did you mean: add_term
2017 Aug 23
0
MASS:::dropterm.glm() and MASS:::addterm.glm() should use ... for extractAIC()
...the R-core, I don't know if the message should have been sent here. Anyway, I have added a copy to Pr Ripley. I hope it could have been fixed. Sincerely Marc Le 09/07/2017 ? 16:05, Marc Girondot via R-devel a ?crit?: > Here is a change required from MASS:::dropterm.glm() and > MASS:::addterm.glm(). > > Thanks > > Marc > > > The stepAIC() function from package MASS uses extractAIC() to get the > AIC from a model. > Several methods exist: > extractAIC.glm() for example, some in MASS packages and some in stats > package. > > The parameters for extr...
2003 Jun 25
2
probelem of function inside function
...30))) > testdata x y 1 129 89 2 109 118 3 52 99 4 118 137 5 217 34 6 278 14 7 606 130 8 198 30 9 99 131 10 133 30 I have write a simple function (nonsense): > f.fun<-function(var,fdata) { fdata<-data.frame(fdata) fit<-lm(y~1,data=fdata) f.addterm<-function(x,fit,f.data) { fdata<-f.data fff<-paste('~.',x,sep='+') try(addterm(fit,as.formula(fff))$AIC[2]) } f.addterm(var,fit,fdata) } This function simply add the "x" variale to the linear regression with intercept only using addterm, an...
2005 Feb 25
0
Problem using stepAIC/addterm (MASS package)
...However, if I try to evaluate "pred.function" for a specific data set, R sometimes stops with the message --- Error in inherits(x, "data.frame") : Object "learndata" not found --- Debugging "stepAIC" showed me that the problem occurs in the step where "addterm" is called. "addterm" somehow doesn't seem to see the object "learndata" which is present (?) in the function's environment. Here is my code. The dataset "BostonHousing" is just an example for which this problem can be observed. "my.MC" is inspi...
2005 Aug 15
2
stepAIC invalid scope argument
...8, sd=0.5) # pairs(df); head(df) lo <- aov( y ~ 1, data=df ) hi <- aov( y ~ .^2, data=df ) mid <- aov( y ~ x2 + x3, data=df ) Running any of the following commands stepAIC( mid, scope=list(upper = ~x1 + x2 + x3 , lower = ~1) ) stepAIC( mid, scope=list(upper = hi , lower = lo) ) addterm( mid, ~ x1 + x2 + x3 ) addterm( lo, hi ) gives the same error message : Error in eval(expr, envir, enclos) : invalid second argument Here is a traceback of the first failed command : 14: eval(predvars, data, env) 13: model.frame.default(formula = y ~ x2 + x3 + x1, data = df, drop.unused.lev...
2012 Oct 30
2
error in lm
Hi everybody I am trying to run the next code but I have the next problem Y1<-cbind(score.sol, score.com.ext, score.pur) > vol.lm<-lm(Y1~1, data=vol14.df) > library(MASS) > stepAIC(vol.lm,~fsex+fjob+fage+fstudies,data=vol14.df) Start: AIC=504.83 Y1 ~ 1 Error in addterm.mlm(fit, scope$add, scale = scale, trace = max(0, trace - : no addterm method implemented for "mlm" models Does anybody knows why I get this error? Thanks in advance Paola -- View this message in context: http://r.789695.n4.nabble.com/error-in-lm-tp4647840.html Sent from the R he...
2017 Jun 08
1
stepAIC() that can use new extractAIC() function implementing AICc
I would like test AICc as a criteria for model selection for a glm using stepAIC() from MASS package. Based on various information available in WEB, stepAIC() use extractAIC() to get the criteria used for model selection. I have created a new extractAIC() function (and extractAIC.glm() and extractAIC.lm() ones) that use a new parameter criteria that can be AIC, BIC or AICc. It works as
2007 Mar 13
3
inconsistent behaviour of add1 and drop1 with a weighted linear model
...sum(example$weights) [1] 13.00000 > model<-lm(y~1,data=example,weights=weights) > add1(model,.~.+x1+x2) Single term additions Model: y ~ 1 Df Sum of Sq RSS AIC <none> 94.000 27.719 x1 1 55.290 38.710 18.185 x2 1 58.630 35.371 17.012 > addterm(model,.~.+x1+x2) Single term additions Model: y ~ 1 Df Sum of Sq RSS AIC <none> 94.000 27.719 x1 1 55.290 38.710 18.185 x2 1 58.630 35.371 17.012 #so add1 and addterm (MASS package) give the same answer, nothing obviously untoward, but #both SS and...
2002 Apr 01
0
something confusing about stepAIC
Folks, I'm using stepAIC(MASS) to do some automated, exploratory, model selection for binomial and Poisson glm models in R 1.3. Because I wanted to experiment with the small-sample correction AICc, I dug around in the code for the functions glm.fit stepAIC dropterm.glm addterm.glm extractAIC.glm and came across something I just don't understand. stepAIC() passes dropterm.glm() a model object. dropterm.glm() then fits a number of submodels, computing for each some measure DeltaFit of the relative change in goodness of fit. It then returns to stepAIC() with some indi...
2003 Apr 28
2
stepAIC/lme problem (1.7.0 only)
I can use stepAIC on an lme object in 1.6.2, but I get the following error if I try to do the same in 1.7.0: Error in lme(fixed = resp ~ cov1 + cov2, data = a, random = structure(list( : unused argument(s) (formula ...) Does anybody know why? Here's an example: library(nlme) library(MASS) a <- data.frame( resp=rnorm(250), cov1=rnorm(250), cov2=rnorm(250),
2012 Jan 22
1
How to construct a formula
Hi, I need to construct a formula programaticly, and pass it to a function such as the linear mixed model lme. The help says it requires "a two-sided linear formula object describing the fixed-effects part of the model" but I do not know how to create this formula. I have tried various things using formula(x, ...), as.formula(object, env = parent.frame()) and as.Formula(x, ...)
2002 Nov 05
1
add1 in glm
I'm having a bit of difficulty using the stepwise model-building tools in a glm context. Here, for example is one problem I have had using add1, where the abbreviation "." does not work as I expected it to do. I someone could point me towards some examples involving the interactive building of glm models I would be grateful. The data set that I am using is the
2013 Jun 25
1
F statistic in add1.lm vs add1.glm
Should the F statistic be the same when using add1() on models created by lm and glm(family=gaussian)? They are in the single-degree-of-freedom case but not in the multiple-degree-of-freedom case. MASS:addterm shows the same discrepancy. It looks like the deviance (==residual sum of squares) gets divided by the number of degrees of freedom for the term twice in add1.glm. Using anova() on the output of lm and glm(family=gaussian) gives the save F statistic as add1.lm gives. > # factor(carb) consumes...
2009 May 05
0
stepAICc function (based on MASS:::stepAIC.default)
Dear all, I have tried to modify the code of MASS:::stepAIC.default(), dropterm() and addterm() to use AICc instead of AIC for model selection. The code is appended below. Somehow the calculations are still not correct and I would be grateful if anyone could have a look at what might be wrong with this code... Here is a working example: ## require(nlme) model1=lme(distance ~ age + Sex, d...
2010 Mar 16
0
New package: ordinal
...a link function-parameter bridges the log-log, probit and c-loglog links (log-gamma), and cloglog and logistic links (Aranda-Ordaz) - a suite of optimizers including an efficient Newton scheme. - works for binomial observations (a special case of ordinal data). - a suite of methods including anova, addterm, dropterm, profile, confint, plot.profile, predict, in addition to the standard print and summary methods. - an important special case is the proportional odds model (with random effects). - a range of examples illustrates how to use the functions. Future additions will include: - more general ran...
2003 Oct 23
0
anova model refinement/clustering question
Hi, I am trying to refine models of a continuous response variable and a number of categorical predictor variables. I know of some model refinement tools available in R that help in the selection of model terms like dropterm and addterm from MASS etc. However, I would also like to try to refine the model by 'coalescing' some levels of some of the predictor factors. Is there a standard procedure / R-functions that will allow me to do this. This might be naive but I thought that one way to do this is to perform a pairwise c...
2008 Oct 11
1
step() and stepAIC()
The birth weight example from ?stepAIC in package MASS runs well as indeed it should. However when I change stepAIC() calls to step() calls I get warning messages that I don't understand, although the output is similar. Warning messages: 1: In model.response(m, "numeric") : using type="numeric" with a factor response will be ignored (and three more the same.) Checked
2010 Mar 16
0
New package: ordinal
...a link function-parameter bridges the log-log, probit and c-loglog links (log-gamma), and cloglog and logistic links (Aranda-Ordaz) - a suite of optimizers including an efficient Newton scheme. - works for binomial observations (a special case of ordinal data). - a suite of methods including anova, addterm, dropterm, profile, confint, plot.profile, predict, in addition to the standard print and summary methods. - an important special case is the proportional odds model (with random effects). - a range of examples illustrates how to use the functions. Future additions will include: - more general ran...
2010 Oct 21
0
compile xapian-extras
...03/11/xappy-now-supports-image-similarity-searching/ ) I complie xapian-extras and xapian-extras-bindings with python. import xapian import xapian.imgseek doc = xapian.Document() imgsig = xapian.imgseek.ImgSig.register_Image(JPEG_PATH) imgterms = xapian.imgseek.ImgTerms('A', 300) imgterms.AddTerms(doc,imgsig) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: in method 'ImgTerms_AddTerms', argument 2 of type 'Xapian::Document &' Please give some suggestion,Thanks!
2009 Jan 23
2
R stepping through multiplie interactions
I have a lm in R in the form model <- lm( Z ~ A*B*C*D,data=mydata) I want to run the model and include all interactions expect the 4 way (A:B:C:D) is there an easy way of doing this? I then want to step down the model eliminating the non-significant terms I understand step() does this but how would I do it by hand? -- View this message in context:
2008 Aug 01
5
drop1() seems to give unexpected results compare to anova()
...ed up with y = 4 * x1 + 5 * x2 + 6 * x3 and R did not add x4 into the model as expected. summary(model1 <- lm(y ~ 1, data = sim.set)) step(model1, direction = 'both', scope = .~. + x1 + x2 + x3 + x4, test = 'F') add1(model1, scope = .~. + x1 + x2 + x3 + x4, test = 'F') addterm(model1, scope = .~. + x1 + x2 + x3 + x4, test = 'F') Df Sum of Sq RSS AIC F value Pr(F) <none> 22107.0 943.1 x1 1 8686.1 13420.8 845.2 128.1478 <2e-16 *** x2 1 11658.7 10448.3 795.2 220.9377 <2e-16 *** x3 1 11045.4 11061.6 806.6 197.7096 <2e-16 *** x4 1 13.4 22093.6 944.9 0...